JDocument/addStyleDeclaration
From Joomla! Documentation
< JDocument(Difference between revisions)
m (Missed & in code sample.) |
(→Example) |
||
| Line 24: | Line 24: | ||
<source lang="php"> | <source lang="php"> | ||
$doc =& JFactory::getDocument(); | $doc =& JFactory::getDocument(); | ||
| − | $style = ' | + | $style = 'BODY1 {' |
. 'background: #00ff00;' | . 'background: #00ff00;' | ||
. 'color: rgb(0,0,255);' | . 'color: rgb(0,0,255);' | ||
| Line 30: | Line 30: | ||
$doc->addStyleDeclaration( $style ); | $doc->addStyleDeclaration( $style ); | ||
</source> | </source> | ||
| + | |||
===See also=== | ===See also=== | ||
* [http://api.joomla.org/Joomla-Framework/Document/JDocument.html#addStyleDeclaration JDocument->addStyleDeclaration on api.joomla.org] | * [http://api.joomla.org/Joomla-Framework/Document/JDocument.html#addStyleDeclaration JDocument->addStyleDeclaration on api.joomla.org] | ||
* [[JDocument/addStyleSheet|JDocument->addStyleSheet]] | * [[JDocument/addStyleSheet|JDocument->addStyleSheet]] | ||
<noinclude>[[Category:Development]][[Category:Framework]][[Category:JDocument]]</noinclude> | <noinclude>[[Category:Development]][[Category:Framework]][[Category:JDocument]]</noinclude> | ||
Revision as of 07:49, 2 April 2009
Adds an internal stylesheet to the document object. The stylesheet is appended to the document objects' internal stylesheet buffer for the specified type.
Syntax
void addStyleDeclaration( $content, $type )
where:
| Argument | Data type | Description | Default |
|---|---|---|---|
| $content | string | Stylesheet content. | |
| $type | string | MIME type of stylesheet. | 'text/css' |
Example
To add a CSS style to the document, you could use:
$doc =& JFactory::getDocument(); $style = 'BODY1 {' . 'background: #00ff00;' . 'color: rgb(0,0,255);' . '}'; $doc->addStyleDeclaration( $style );