JDocument/addStyleSheet
From Joomla! Documentation
< JDocument(Difference between revisions)
m (Fixed bizarre double quotes) |
m (Example depends on document type.) |
||
| Line 34: | Line 34: | ||
<source lang="php"> | <source lang="php"> | ||
$doc =& JFactory::getDocument(); | $doc =& JFactory::getDocument(); | ||
| − | $doc->addStyleSheet( | + | $doc->addStyleSheet( “http://www.example.com/css/mystylesheet.css” ); |
</source> | </source> | ||
| − | + | How this is rendered depends on the document type. If the document type is HTML then this code will produce following link in the HTML HEAD section: | |
| − | + | <source lang="html4strict"> | |
| − | <source lang=" | + | |
<link rel="stylesheet" href="http://www.example.com/css/mystylesheet.css" type="text/css" /> | <link rel="stylesheet" href="http://www.example.com/css/mystylesheet.css" type="text/css" /> | ||
</source> | </source> | ||
Revision as of 12:14, 10 November 2008
Adds the definition of a linked external stylesheet to the document. Duplicates are ignored.
Syntax
void addStyleSheet( $url, $type, $media, $attribs )
where:
| Argument | Data type | Description | Default |
|---|---|---|---|
| $url | string | URL of stylesheet. | |
| $type | string | MIME type of script. | 'text/css' |
| $media | string | Media type that the stylesheet applies to. | null |
| $attribs | array | Array of attributes. |
Example
To add a link to some style sheet at a specific URL, you could use:
$doc =& JFactory::getDocument(); $doc->addStyleSheet( “http://www.example.com/css/mystylesheet.css” );
How this is rendered depends on the document type. If the document type is HTML then this code will produce following link in the HTML HEAD section:
<link rel="stylesheet" href="http://www.example.com/css/mystylesheet.css" type="text/css" />