Difference between revisions of "JHtml/stylesheet"
From Joomla! Documentation
< API16:JHtml
(New page: ===Description===
Write a <link rel="stylesheet" style="text/css"> element
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JHtml/stylesheet|Edi...) |
m (removing red link to edit, no existant pages) |
||
Line 3: | Line 3: | ||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
− | <nowiki>[< | + | <nowiki>[<! removed edit link to red link >]</nowiki> |
</span> | </span> | ||
− | + | <! removed transcluded page call, red link never existed > | |
===Syntax=== | ===Syntax=== | ||
Line 83: | Line 83: | ||
<span class="editsection" style="font-size:76%;"> | <span class="editsection" style="font-size:76%;"> | ||
− | <nowiki>[< | + | <nowiki>[<! removed edit link to red link >]</nowiki> |
</span> | </span> | ||
− | + | <! removed transcluded page call, red link never existed > | |
===Examples=== | ===Examples=== | ||
Line 98: | Line 98: | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
+ | [[Category:Archived pages API16]] |
Revision as of 21:55, 13 May 2013
The "API16" 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.
Description[edit]
Write a <link rel="stylesheet" style="text/css"> element
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
Syntax[edit]
static stylesheet($file, $attribs=array(), $relative=false, $path_only=false)
Parameter Name | Default Value | Description |
---|---|---|
$file | path to file | |
$attribs | array() | attributes to be added to the stylesheet |
$relative | false | path to file is relative to /media folder |
$path_only | false | return the path to the file only |
Defined in[edit]
libraries/joomla/html/html.php
Importing[edit]
jimport( 'joomla.html.html' );
Source Body[edit]
public static function stylesheet($file, $attribs = array(), $relative = false, $path_only = false)
{
if (is_array($attribs)) {
$attribs = JArrayHelper::toString($attribs);
}
if($relative)
{
$app = JFactory::getApplication();
$cur_template = $app->getTemplate();
if (file_exists(JPATH_THEMES .'/'. $cur_template .'/css/'. $file)) {
$file = JURI::base(true).'/templates/'. $cur_template .'/css/'. $file;
} else {
list($extension, $file) = explode('/', $file, 2);
if (strpos($file, '/')) {
// Try to deal with plugins group
list($element, $file) = explode('/', $file, 2);
if (file_exists(JPATH_ROOT .'/media/'.$extension.'/'.$element.'/css/'.$file)) {
$file = JURI::root(true).'/media/'.$extension.'/'.$element.'/css/'.$file;
} else {
$file = JURI::root(true).'/media/'.$extension.'/css/'.$element.'/'.$file;
}
}
else {
$file = JURI::root(true).'/media/'.$extension.'/css/'.$file;
}
}
if($path_only)
{
return $file;
}
} elseif (strpos($file, 'http') !== 0) {
$file = JURI::root(true).'/'.$file;
}
$document = &JFactory::getDocument();
$document->addStylesheet($file, 'text/css', null, $attribs);
return;
}
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples[edit]
<CodeExamplesForm />