As I already mentioned in #16174 ...
Having notices/warnings enabled, you might see several messages like
Warning: Illegal string offset 'relative' in ./libraries/src/HTML/HTMLHelper.php on line 626
(Joomla3.x)
or
Warning: Illegal string offset 'relative' in ./libraries/src/HTML/HTMLHelper.php on line 715
(Joomla4Alpha)
These messages are mostly caused by adding a stylesheet the old way, e.g.:
JHTML::stylesheet(filename,path)
instead of the correct "new" way
$document->addStyleSheet(path-to-css-file)
Of course, the reason is an outdated code (mostly in templates, but also other extensions), but is caused by Joomla itself ... even in Joomla 4Alpha3.
Imho this method should get removed completely to force developers to finally update their code, otherwise this should be corrected by some "if(array_key_exists(...))" to avoid these warnings ;)
Greetz
Labels |
Added:
?
|
Category | ⇒ | Libraries Templates (site) |
Status | New | ⇒ | Discussion |
FWIW the proper method to add stylesheets and script ARE and will remain for Joomla 4 the: HTMLHelper::stylesheet and HTMLHelper::script (NOT $document->addStyleSheet)
What was deprecated and will be removed is the option to pass the parameters as comma separated. Now it's mandatory to pass them using an array, eg:
OLD WAY
HTMLHelper::_('script', 'some/path/to/script.js', true, true, false, true);
NEW WAY
HTMLHelper::_('script', 'some/path/to/script.js', array('relative' => true, 'version' => 'auto', 'pathOnly' => false, 'debug' => true);
PLEASE DONT USE $document->addStyleSheet
AS YOUR ASSETS WILL NOT BBE OVERRIDABLE!!!
I get your point dgrammatiko
But then I recommend to change in HTMLHelper.php at the beginning of public static function stylesheet() from currently
if (!is_array($attribs))
to
if (!is_array($attribs) || !is_array($options))
since the css wont get included with these parameters anyway.
But this way the notices are gone and eventually a deprecated message is logged
Labels |
Added:
J3 Issue
|
Status | Discussion | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-08-19 19:35:33 |
Closed_By | ⇒ | brianteeman |
Methods script() and stylesheet() are marked inside docblock with:
So, I think the concerning parts will be removed finally in Joomla 4.