JDocument: Difference between revisions
From Joomla! Documentation
New page: <span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki>
</span>
{{Description:JDocument}}
===Defined in===
l... |
m preparing for archive only |
||
| (3 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
[[JDocument]] is an abstract class which provides a number of methods and properties appropriate for a range of document types. Some of the methods listed will be overridden by the child class so you should check the child class documentation for further information. | |||
===Defined in=== | ===Defined in=== | ||
| Line 123: | Line 120: | ||
|Outputs the document | |Outputs the document | ||
|} | |} | ||
===Importing=== | ===Importing=== | ||
<source lang="php">jimport( 'joomla.document.document' );</source> | <source lang="php">jimport( 'joomla.document.document' );</source> | ||
===Examples=== | ===Examples=== | ||
=== Code Examples === | |||
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=JDocument | category=JDocument | ||
namespace=CodeExample | |||
category=ClassExample | category=ClassExample | ||
include=* | include=* | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
Latest revision as of 00:29, 25 March 2017
JDocument is an abstract class which provides a number of methods and properties appropriate for a range of document types. Some of the methods listed will be overridden by the child class so you should check the child class documentation for further information.
Defined in
libraries/joomla/document/document.php
Methods
| Method name | Description |
|---|---|
| __construct | Class constructor |
| getInstance | Returns a reference to the global JDocument object, only creating it if it doesn't already exist. |
| setType | Set the document type |
| getType | Returns the document type |
| getHeadData | Get the document head data |
| setHeadData | Set the document head data |
| getBuffer | Get the contents of the document buffer |
| setBuffer | Set the contents of the document buffer |
| getMetaData | Gets a meta tag. |
| setMetaData | Sets or alters a meta tag. |
| addScript | Adds a linked script to the page |
| addScriptDeclaration | Adds a script to the page |
| addStyleSheet | Adds a linked stylesheet to the page |
| addStyleDeclaration | Adds a stylesheet declaration to the page |
| setCharset | Sets the document charset |
| getCharset | Returns the document charset encoding. |
| setLanguage | Sets the global document language declaration. Default is English (en-gb). |
| getLanguage | Returns the document language. |
| setDirection | Sets the global document direction declaration. Default is left-to-right (ltr). |
| getDirection | Returns the document language. |
| setTitle | Sets the title of the document |
| getTitle | Return the title of the document. |
| setBase | Sets the base URI of the document |
| getBase | Return the base URI of the document. |
| setDescription | Sets the description of the document |
| getDescription | Return the title of the page. |
| setLink | Sets the document link |
| getLink | Returns the document base url |
| setGenerator | Sets the document generator |
| getGenerator | Returns the document generator |
| setModifiedDate | Sets the document modified date |
| getModifiedDate | Returns the document modified date |
| setMimeEncoding | Sets the document MIME encoding that is sent to the browser. |
| setLineEnd | Sets the line end style to Windows, Mac, Unix or a custom string. |
| setTab | Sets the string used to indent HTML |
| loadRenderer | Load a renderer |
| render | Outputs the document |
Importing
jimport( 'joomla.document.document' );
New document types are added by creating a new sub-directory under the /libraries/joomla/document/ directory with the same name as the type. For example, to add a document type called "mytype", you would create the directory /libraries/joomla/document/mytype. In this directory you must then create a file called mytype.php which will contain the class definition for JDocumentMytype which extends JDocument. Look at the code for existing document types to see what needs to be done.