According to the wiki page Adding Javascript and CSS to the Page, you can add a stylesheet with addStyleSheet
like this:
$document = JFactory::getDocument();
$document->addStyleSheet($url);
Or with JHtml::stylesheet
like this:
JHtml::stylesheet($url, array(), true);
But the wiki page Creating a Basic Template instructs the learner to include stylesheets like this:
<head>
<jdoc:include type="head" />
<link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/system/css/system.css">
</head>
This bypasses addStyleSheet
and JHtml::stylesheet
. Is this a good idea? When would you use the former and when would you use the latter?
Note: JHtml::_("script", …)
and JHtml::_("stylesheet", …)
are almost exactly the same as JHtml::script
and JHtml::stylesheet
. See What does JHtml::_
do.