In my Joomla component i add a style sheet according to phpstorm is $document->addStyleSheet deprecated.
This is the code i use:
$uri = JUri::base();
$document = JFactory::getDocument();
$document->addStyleSheet(JUri::base() . "components/com_exampe/views/stats/tmpl/style.css");
I also tryed this code:
JHtml::stylesheet('com_hccxmlkadernet/views/statistiek/tmpl/style.css', array(), true);
But thats also deprecated
Can some one tell what te correct way is to do this ?
According to this page: https://api.joomla.org/cms-3/classes/Joomla.CMS.Document.Document.html#method_addStyleSheet
It says addStyleSheet() is deprecated. Actually the whole method is not deprecated, it's just that the expected arguments have slightly changed.
v4.0 (url, mime, media, attribs) method signature is deprecated, use (url, options, attributes) instead.
So, as long as you use;
$document->addStyleSheet($url)
You don't need to worry about anything, you are good to go (because arg1 is $url in both version).
Don't use JHTML. It has been deprecated in J2.5 and removed from J3.x:
It used to be possible to do this with JHTML, however, this was deprecated in Joomla 2.5 and removed in Joomla 3.x.
reference: https://docs.joomla.org/J3.x:Adding_JavaScript_and_CSS_to_the_page