From Joomla! Documentation

The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

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[edit]



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


jimport( 'joomla.document.document' );


Code Examples[edit]

Adding support for new document types

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.

Chris Davenport 12:35, 17 April 2011 (CDT) Edit comment