Actions

Difference between revisions of "JDocument/addStyleDeclaration"

From Joomla! Documentation

(New page: 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 addStyleDeclar...)
 
m (Missed & in code sample.)
Line 23: Line 23:
 
To add a CSS style to the document, you could use:
 
To add a CSS style to the document, you could use:
 
<source lang="php">
 
<source lang="php">
$doc = JFactory::getDocument();
+
$doc =& JFactory::getDocument();
 
$style = 'BODY {'
 
$style = 'BODY {'
 
. 'background: #00ff00;'
 
. 'background: #00ff00;'

Revision as of 05:01, 8 September 2008

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 = 'BODY {'
        . 'background: #00ff00;'
        . 'color: rgb(0,0,255);'
        . '}'; 
$doc->addStyleDeclaration( $style );

See also