Back to Document class

Method addStyleSheet

public \Joomla\CMS\Document\Document
addStyleSheet
(mixed $url, mixed $options = array(), mixed $attribs = array())
Adds a linked stylesheet to the page
Parameters
  • string $url URL to the linked style sheet
  • array $options Array of options. Example: array('version' => 'auto', 'conditional' => 'lt IE 9', 'preload' => array('preload'))
  • array $attribs Array of attributes. Example: array('id' => 'stylesheet', 'data-test' => 1)
Returns
  • \Joomla\CMS\Document\Document instance of $this to allow chaining
Since
  • 1.7.0
Deprecated
  • 5.0
Class: Document
Project: Joomla

Method addStyleSheet - Source code

/**
 * Adds a linked stylesheet to the page
 *
 * @param   string  $url      URL to the linked style sheet
 * @param   array   $options  Array of options. Example: array('version' => 'auto', 'conditional' => 'lt IE 9', 'preload' => array('preload'))
 * @param   array   $attribs  Array of attributes. Example: array('id' => 'stylesheet', 'data-test' => 1)
 *
 * @return  Document instance of $this to allow chaining
 *
 * @since   1.7.0
 *
 * @deprecated 5.0  Use WebAssetManager
 */
public function addStyleSheet($url, $options = array(), $attribs = array())
{
    // Default value for type.
    if (!isset($attribs['type']) && !isset($attribs['mime'])) {
        $attribs['type'] = 'text/css';
    }
    $this->_styleSheets[$url] = isset($this->_styleSheets[$url]) ? array_replace($this->_styleSheets[$url], $attribs) : $attribs;
    if (isset($this->_styleSheets[$url]['options'])) {
        $this->_styleSheets[$url]['options'] = array_replace($this->_styleSheets[$url]['options'], $options);
    } else {
        $this->_styleSheets[$url]['options'] = $options;
    }
    return $this;
}