HtmlDocument
Extends DocumentHtmlDocument class, provides an easy interface to parse and display a HTML document
| since |
1.7.0 |
|---|---|
| package |
Joomla CMS |
Methods
__construct
Class constructor.
__construct(array options = array()) : mixed
| since |
1.7.0 |
|---|
Arguments
- options
arrayAssociative array of options
Response
mixed
_fetchTemplate
Fetch the template, and initialise the params
_fetchTemplate(array params = array()) : \Joomla\CMS\Document\HtmlDocument
| since |
1.7.0 |
|---|
Arguments
- params
arrayParameters to determine the template
Response
\Joomla\CMS\Document\HtmlDocumentinstance of $this to allow chaining
_getLineEnd
Returns the lineEnd
_getLineEnd() : string
| since |
1.7.0 |
|---|
Response
string
_getTab
Returns a string containing the unit for indenting HTML
_getTab() : string
| since |
1.7.0 |
|---|
Response
string
_loadTemplate
Load a template file
_loadTemplate(string directory, string filename) : string
| since |
1.7.0 |
|---|
Arguments
- directory
stringThe name of the template- filename
stringThe actual filename
Response
stringThe contents of the template
_parseTemplate
Parse a document template
_parseTemplate() : \Joomla\CMS\Document\HtmlDocument
| since |
1.7.0 |
|---|
Response
\Joomla\CMS\Document\HtmlDocumentinstance of $this to allow chaining
_renderTemplate
Render pre-parsed template
_renderTemplate() : string
| since |
1.7.0 |
|---|
Response
stringrendered template
addCustomTag
Adds a custom HTML string to the head block
addCustomTag(string html) : \Joomla\CMS\Document\HtmlDocument
| since |
1.7.0 |
|---|
Arguments
- html
stringThe HTML to add to the head
Response
\Joomla\CMS\Document\HtmlDocumentinstance of $this to allow chaining
addFavicon
Adds a shortcut icon (favicon)
addFavicon(string href, string type = 'image/vnd.microsoft.icon', string relation = 'shortcut icon') : \Joomla\CMS\Document\HtmlDocument
This adds a link to the icon shown in the favorites list or on the left of the url in the address bar. Some browsers display it on the tab, as well.
| since |
1.7.0 |
|---|
Arguments
- href
stringThe link that is being related.- type
stringFile type- relation
stringRelation of link
Response
\Joomla\CMS\Document\HtmlDocumentinstance of $this to allow chaining
addHeadLink
Adds <link> tags to the head of the document
addHeadLink(string href, string relation, string relType = 'rel', array attribs = array()) : \Joomla\CMS\Document\HtmlDocument
$relType defaults to 'rel' as it is the most common relation type used.
('rev' refers to reverse relation, 'rel' indicates normal, forward relation.)
Typical tag: <link href="index.php" rel="Start">
| since |
1.7.0 |
|---|
Arguments
- href
stringThe link that is being related.- relation
stringRelation of link.- relType
stringRelation type attribute. Either rel or rev (default: 'rel').- attribs
arrayAssociative array of remaining attributes.
Response
\Joomla\CMS\Document\HtmlDocumentinstance of $this to allow chaining
addScript
Adds a linked script to the page
addScript(string url, array options = array(), array attribs = array()) : \Joomla\CMS\Document\Document
| since |
1.7.0 |
|---|---|
| deprecated |
4.0 The (url, mime, defer, async) method signature is deprecated, use (url, options, attributes) instead. |
Arguments
- url
stringURL to the linked script.- options
arrayArray of options. Example: array('version' => 'auto', 'conditional' => 'lt IE 9')- attribs
arrayArray of attributes. Example: array('id' => 'scriptid', 'async' => 'async', 'data-test' => 1)
Response
\Joomla\CMS\Document\Documentinstance of $this to allow chaining
addScriptDeclaration
Adds a script to the page
addScriptDeclaration(string content, string type = 'text/javascript') : \Joomla\CMS\Document\Document
| since |
1.7.0 |
|---|
Arguments
- content
stringScript- type
stringScripting mime (defaults to 'text/javascript')
Response
\Joomla\CMS\Document\Documentinstance of $this to allow chaining
addScriptOptions
Add option for script
addScriptOptions(string key, mixed options, bool merge = true) : \Joomla\CMS\Document\Document
| since |
3.5 |
|---|
Arguments
- key
stringName in Storage- options
mixedScrip options as array or string- merge
boolWhether merge with existing (true) or replace (false)
Response
\Joomla\CMS\Document\Documentinstance of $this to allow chaining
addScriptVersion
Adds a linked script to the page with a version to allow to flush it. Ex: myscript.js?54771616b5bceae9df03c6173babf11d If not specified Joomla! automatically handles versioning
addScriptVersion(string url, array options = array(), array attribs = array()) : \Joomla\CMS\Document\Document
| since |
3.2 |
|---|---|
| deprecated |
4.0 This method is deprecated, use addScript(url, options, attributes) instead. |
Arguments
- url
stringURL to the linked script.- options
arrayArray of options. Example: array('version' => 'auto', 'conditional' => 'lt IE 9')- attribs
arrayArray of attributes. Example: array('id' => 'scriptid', 'async' => 'async', 'data-test' => 1)
Response
\Joomla\CMS\Document\Documentinstance of $this to allow chaining
addStyleDeclaration
Adds a stylesheet declaration to the page
addStyleDeclaration(string content, string type = 'text/css') : \Joomla\CMS\Document\Document
| since |
1.7.0 |
|---|
Arguments
- content
stringStyle declarations- type
stringType of stylesheet (defaults to 'text/css')
Response
\Joomla\CMS\Document\Documentinstance of $this to allow chaining
addStyleSheet
Adds a linked stylesheet to the page
addStyleSheet(string url, array options = array(), array attribs = array()) : \Joomla\CMS\Document\Document
| since |
1.7.0 |
|---|---|
| deprecated |
4.0 The (url, mime, media, attribs) method signature is deprecated, use (url, options, attributes) instead. |
Arguments
- url
stringURL to the linked style sheet- options
arrayArray of options. Example: array('version' => 'auto', 'conditional' => 'lt IE 9')- attribs
arrayArray of attributes. Example: array('id' => 'stylesheet', 'data-test' => 1)
Response
\Joomla\CMS\Document\Documentinstance of $this to allow chaining
addStyleSheetVersion
Adds a linked stylesheet version to the page. Ex: template.css?54771616b5bceae9df03c6173babf11d If not specified Joomla! automatically handles versioning
addStyleSheetVersion(string url, array options = array(), array attribs = array()) : \Joomla\CMS\Document\Document
| since |
3.2 |
|---|---|
| deprecated |
4.0 This method is deprecated, use addStyleSheet(url, options, attributes) instead. |
Arguments
- url
stringURL to the linked style sheet- options
arrayArray of options. Example: array('version' => 'auto', 'conditional' => 'lt IE 9')- attribs
arrayArray of attributes. Example: array('id' => 'stylesheet', 'data-test' => 1)
Response
\Joomla\CMS\Document\Documentinstance of $this to allow chaining
countMenuChildren
Count the number of child menu items of the current active menu item
countMenuChildren() : int
| since |
1.7.0 |
|---|
Response
intNumber of child menu items
countModules
Count the modules based on the given condition
countModules(string condition) : int
| since |
1.7.0 |
|---|
Arguments
- condition
stringThe condition to use
Response
intNumber of modules found
getBase
Return the base URI of the document.
getBase() : string
| since |
1.7.0 |
|---|
Response
string
getBuffer
Get the contents of the document buffer
getBuffer() : mixed
| since |
1.7.0 |
|---|
Response
mixed
getCharset
Returns the document charset encoding.
getCharset() : string
| since |
1.7.0 |
|---|
Response
string
getDescription
Return the description of the document.
getDescription() : string
| since |
1.7.0 |
|---|
Response
string
getDirection
Returns the document direction declaration.
getDirection() : string
| since |
1.7.0 |
|---|
Response
string
getGenerator
Returns the document generator
getGenerator() : string
| since |
1.7.0 |
|---|
Response
string
getHeadData
Get the HTML document head data
getHeadData() : array
| since |
1.7.0 |
|---|
Response
arrayThe document head data in array form
getInstance
Returns the global Document object, only creating it if it doesn't already exist.
getInstance(string type = 'html', array attributes = array()) : object
| since |
1.7.0 |
|---|
Arguments
- type
stringThe document type to instantiate- attributes
arrayArray of attributes
Response
objectThe document object.
getLanguage
Returns the document language.
getLanguage() : string
| since |
1.7.0 |
|---|
Response
string
getLink
Returns the document base url
getLink() : string
| since |
1.7.0 |
|---|
Response
string
getMediaVersion
Return the media version
getMediaVersion() : string
| since |
3.2 |
|---|
Response
string
getMetaData
Gets a meta tag.
getMetaData(string name, string attribute = 'name') : string
| since |
1.7.0 |
|---|
Arguments
- name
stringName of the meta HTML tag- attribute
stringAttribute to use in the meta HTML tag
Response
string
getMimeEncoding
Return the document MIME encoding that is sent to the browser.
getMimeEncoding() : string
| since |
1.7.0 |
|---|
Response
string
getModifiedDate
Returns the document modified date
getModifiedDate() : string|\Joomla\CMS\Date\Date
| since |
1.7.0 |
|---|
Response
string|\Joomla\CMS\Date\Date
getScriptOptions
Get script(s) options
getScriptOptions(string key = null) : array
| since |
3.5 |
|---|
Arguments
- key
stringName in Storage
Response
arrayOptions for given $key, or all script options
getTitle
Return the title of the document.
getTitle() : string
| since |
1.7.0 |
|---|
Response
string
getType
Returns the document type
getType() : string
| since |
1.7.0 |
|---|
Response
string
isHtml5
Returns whether the document is set up to be output as HTML5
isHtml5() : bool
| since |
3.0.0 |
|---|
Response
booltrue when HTML5 is used
loadRenderer
Load a renderer
loadRenderer(string type) : \Joomla\CMS\Document\DocumentRenderer
| since |
1.7.0 |
|---|---|
| throws |
|
Arguments
- type
stringThe renderer type
Response
\Joomla\CMS\Document\DocumentRenderer
mergeHeadData
Merge the HTML document head data
mergeHeadData(array data) : \Joomla\CMS\Document\HtmlDocument|null
| since |
1.7.0 |
|---|
Arguments
- data
arrayThe document head data in array form
Response
\Joomla\CMS\Document\HtmlDocument|nullinstance of $this to allow chaining or null for empty input data
parse
Parses the document and prepares the buffers
parse(array params = array()) : \Joomla\CMS\Document\Document
| since |
1.7.0 |
|---|
Arguments
- params
arrayThe array of parameters
Response
\Joomla\CMS\Document\Documentinstance of $this to allow chaining
render
Outputs the document
render(bool cache = false, array params = array()) : void
| since |
1.7.0 |
|---|
Arguments
- cache
boolIf true, cache the output- params
arrayAssociative array of attributes
resetHeadData
Reset the HTML document head data
resetHeadData(mixed types = null) : \Joomla\CMS\Document\HtmlDocument
| since |
3.7.0 |
|---|
Arguments
- types
mixedtype or types of the heads elements to reset
Response
\Joomla\CMS\Document\HtmlDocumentinstance of $this to allow chaining
resetHeadDatum
Reset a part the HTML document head data
resetHeadDatum(string type) : void
| since |
3.7.0 |
|---|
Arguments
- type
stringtype of the heads elements to reset
setBase
Sets the base URI of the document
setBase(string base) : \Joomla\CMS\Document\Document
| since |
1.7.0 |
|---|
Arguments
- base
stringThe base URI to be set
Response
\Joomla\CMS\Document\Documentinstance of $this to allow chaining
setBuffer
Set the contents of the document buffer
setBuffer(string content, array options = array()) : \Joomla\CMS\Document\Document
| since |
1.7.0 |
|---|
Arguments
- content
stringThe content to be set in the buffer.- options
arrayArray of optional elements.
Response
\Joomla\CMS\Document\Documentinstance of $this to allow chaining
setCharset
Sets the document charset
setCharset(string type = 'utf-8') : \Joomla\CMS\Document\Document
| since |
1.7.0 |
|---|
Arguments
- type
stringCharset encoding string
Response
\Joomla\CMS\Document\Documentinstance of $this to allow chaining
setDescription
Sets the description of the document
setDescription(string description) : \Joomla\CMS\Document\Document
| since |
1.7.0 |
|---|
Arguments
- description
stringThe description to set
Response
\Joomla\CMS\Document\Documentinstance of $this to allow chaining
setDirection
Sets the global document direction declaration. Default is left-to-right (ltr).
setDirection(string dir = 'ltr') : \Joomla\CMS\Document\Document
| since |
1.7.0 |
|---|
Arguments
- dir
stringThe language direction to be set
Response
\Joomla\CMS\Document\Documentinstance of $this to allow chaining
setGenerator
Sets the document generator
setGenerator(string generator) : \Joomla\CMS\Document\Document
| since |
1.7.0 |
|---|
Arguments
- generator
stringThe generator to be set
Response
\Joomla\CMS\Document\Documentinstance of $this to allow chaining
setHeadData
Set the HTML document head data
setHeadData(array data) : \Joomla\CMS\Document\HtmlDocument|null
| since |
1.7.0 |
|---|
Arguments
- data
arrayThe document head data in array form
Response
\Joomla\CMS\Document\HtmlDocument|nullinstance of $this to allow chaining or null for empty input data
setHtml5
Sets whether the document should be output as HTML5
setHtml5(bool state) : void
| since |
3.0.0 |
|---|
Arguments
- state
boolTrue when HTML5 should be output
setLanguage
Sets the global document language declaration. Default is English (en-gb).
setLanguage(string lang = 'en-gb') : \Joomla\CMS\Document\Document
| since |
1.7.0 |
|---|
Arguments
- lang
stringThe language to be set
Response
\Joomla\CMS\Document\Documentinstance of $this to allow chaining
setLineEnd
Sets the line end style to Windows, Mac, Unix or a custom string.
setLineEnd(string style) : \Joomla\CMS\Document\Document
| since |
1.7.0 |
|---|
Arguments
- style
string"win", "mac", "unix" or custom string.
Response
\Joomla\CMS\Document\Documentinstance of $this to allow chaining
setLink
Sets the document link
setLink(string url) : \Joomla\CMS\Document\Document
| since |
1.7.0 |
|---|
Arguments
- url
stringA url
Response
\Joomla\CMS\Document\Documentinstance of $this to allow chaining
setMediaVersion
Set the assets version
setMediaVersion(string mediaVersion) : \Joomla\CMS\Document\Document
| since |
3.2 |
|---|
Arguments
- mediaVersion
stringMedia version to use
Response
\Joomla\CMS\Document\Documentinstance of $this to allow chaining
setMetaData
Sets or alters a meta tag.
setMetaData(string name, mixed content, string attribute = 'name') : \Joomla\CMS\Document\Document
| since |
1.7.0 |
|---|
Arguments
- name
stringName of the meta HTML tag- content
mixedValue of the meta HTML tag as array or string- attribute
stringAttribute to use in the meta HTML tag
Response
\Joomla\CMS\Document\Documentinstance of $this to allow chaining
setMimeEncoding
Sets the document MIME encoding that is sent to the browser.
setMimeEncoding(string type = 'text/html', bool sync = true) : \Joomla\CMS\Document\Document
This usually will be text/html because most browsers cannot yet accept the proper mime settings for XHTML: application/xhtml+xml and to a lesser extent application/xml and text/xml. See the W3C note ({@link http://www.w3.org/TR/xhtml-media-types/}) for more details.
| since |
1.7.0 |
|---|---|
| link |
Arguments
- type
stringThe document type to be sent- sync
boolShould the type be synced with HTML?
Response
\Joomla\CMS\Document\Documentinstance of $this to allow chaining
setModifiedDate
Sets the document modified date
setModifiedDate(string|\Joomla\CMS\Date\Date date) : \Joomla\CMS\Document\Document
| since |
1.7.0 |
|---|---|
| throws |
|
Arguments
- date
string|\Joomla\CMS\Date\DateThe date to be set
Response
\Joomla\CMS\Document\Documentinstance of $this to allow chaining
setTab
Sets the string used to indent HTML
setTab(string string) : \Joomla\CMS\Document\Document
| since |
1.7.0 |
|---|
Arguments
- string
stringString used to indent ("\11", "\t", ' ', etc.).
Response
\Joomla\CMS\Document\Documentinstance of $this to allow chaining
setTitle
Sets the title of the document
setTitle(string title) : \Joomla\CMS\Document\Document
| since |
1.7.0 |
|---|
Arguments
- title
stringThe title to be set
Response
\Joomla\CMS\Document\Documentinstance of $this to allow chaining
setType
Set the document type
setType(string type) : \Joomla\CMS\Document\Document
| since |
1.7.0 |
|---|
Arguments
- type
stringType document is to set to
Response
\Joomla\CMS\Document\Documentinstance of $this to allow chaining
Properties
_links
Array of Header <link> tags
| since |
1.7.0 |
|---|
Type(s)
array
_custom
Array of custom tags
| since |
1.7.0 |
|---|
Type(s)
array
template
Name of the template
| since |
1.7.0 |
|---|
Type(s)
string
baseurl
Base url
| since |
1.7.0 |
|---|
Type(s)
string
params
Array of template parameters
| since |
1.7.0 |
|---|
Type(s)
array
_file
File name
| since |
1.7.0 |
|---|
Type(s)
array
_template
String holding parsed template
| since |
1.7.0 |
|---|
Type(s)
string
_template_tags
Array of parsed template JDoc tags
| since |
1.7.0 |
|---|
Type(s)
array
_caching
Integer with caching setting
| since |
1.7.0 |
|---|
Type(s)
int
_html5
Set to true when the document should be output as HTML5
| since |
3.0.0 |
|---|---|
| note |
4.0 Will be replaced by $html5 and the default value will be true. |
Type(s)
bool
title
Document title
| since |
1.7.0 |
|---|
Type(s)
string
description
Document description
| since |
1.7.0 |
|---|
Type(s)
string
link
Document full URL
| since |
1.7.0 |
|---|
Type(s)
string
base
Document base URL
| since |
1.7.0 |
|---|
Type(s)
string
language
Contains the document language setting
| since |
1.7.0 |
|---|
Type(s)
string
direction
Contains the document direction setting
| since |
1.7.0 |
|---|
Type(s)
string
_generator
Document generator
| since |
1.7.0 |
|---|
Type(s)
string
_mdate
Document modified date
| since |
1.7.0 |
|---|
Type(s)
string|\Joomla\CMS\Date\Date
_tab
Tab string
| since |
1.7.0 |
|---|
Type(s)
string
_lineEnd
Contains the line end string
| since |
1.7.0 |
|---|
Type(s)
string
_charset
Contains the character encoding string
| since |
1.7.0 |
|---|
Type(s)
string
_mime
Document mime type
| since |
1.7.0 |
|---|
Type(s)
string
_namespace
Document namespace
| since |
1.7.0 |
|---|
Type(s)
string
_profile
Document profile
| since |
1.7.0 |
|---|
Type(s)
string
_scripts
Array of linked scripts
| since |
1.7.0 |
|---|
Type(s)
array
_script
Array of scripts placed in the header
| since |
1.7.0 |
|---|
Type(s)
array
scriptOptions
Array of scripts options
Type(s)
array
_styleSheets
Array of linked style sheets
| since |
1.7.0 |
|---|
Type(s)
array
_style
Array of included style declarations
| since |
1.7.0 |
|---|
Type(s)
array
_metaTags
Array of meta tags
| since |
1.7.0 |
|---|
Type(s)
array
_engine
The rendering engine
| since |
1.7.0 |
|---|
Type(s)
object
_type
The document type
| since |
1.7.0 |
|---|
Type(s)
string
_buffer
Array of buffered output
| since |
1.7.0 |
|---|
Type(s)
mixed
instances
Document instances container.
| since |
1.7.3 |
|---|
Type(s)
array
mediaVersion
Media version added to assets
| since |
3.2 |
|---|
Type(s)
string