?
avatar C-Lodder
C-Lodder
8 Nov 2019

Steps to reproduce the issue

Create a new CSS file here:

administrator/templates/atum/css/vendor/choicesjs/choices.css

Inside this CSS file, add:

html { display: none }

Then go to your Article Manager

Expected result

The page should be blank

Actual result

The CSS file is not overridden

This works perfectly fine with JHtml::stylesheet as it checks if the CSS file exists at template level first.

avatar C-Lodder C-Lodder - open - 8 Nov 2019
avatar joomla-cms-bot joomla-cms-bot - change - 8 Nov 2019
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 8 Nov 2019
avatar C-Lodder C-Lodder - change - 8 Nov 2019
The description was changed
avatar C-Lodder C-Lodder - edited - 8 Nov 2019
avatar C-Lodder
C-Lodder - comment - 8 Nov 2019

@Fedik #25775 doesn't solve this either

avatar Fedik
Fedik - comment - 9 Nov 2019

That not a bug, that is a feature ;)

Well, it was planed like that. So /media/vendor should be overridden only via AssetManager
check comment #26077 (comment)

But that not hard to change, if it need.

avatar C-Lodder
C-Lodder - comment - 9 Nov 2019

@Fedik Which directory do we override the .json file?

avatar Fedik
Fedik - comment - 9 Nov 2019

Which directory do we override the .json file?

no no,
it not like that, no need override "file", but definition of asset.

Take a look https://docs.joomla.org/J4.x:Web_Assets

json just a way to register a bunch of assets in the registry.

Example the asset of /media/vendor defined in media/vendor/joomla.asset.json. To override one of its(vendor) assets on template level you can define your asset with the same name in your template joomla.asset.json. Because the template json will be loaded last, it will override previous assets (from vendor json) by its name, if there the same name.
Or programaticaly $AssetRegistry->add(new WebAssetItem('foobar', ['js' => ['new/path/to/file.js']]));

avatar Fedik
Fedik - comment - 10 Nov 2019

@wilsonge what do you think about the issue?

The main idea was that all scripts/styles that have defined Assets should be loaded and overridden through AssetManager. Since it is a new thing and /media/vendor also "new" folder in j4, I thought it will be safe.
But as we see people can still use HTMLHelper to add the files from /media/vendor that can lead to duplication when the file overridden on template via HTMLHelper.

From other side, if we allow override js/css files in /media/vendor by AssetManager itself (by HTMLHelper while attaching), it will produce the same mistake, example when someone override asset via AssetManager, and another one use HTMLHelper to load old file.

That kind of this issue #25309

We can make some kind of requirement (or statement) that all assets should be managed through AssetManager only. But we cannot prevent to use HTMLHelper directly, because that also should work for compatibility.

avatar C-Lodder
C-Lodder - comment - 14 Nov 2019

@Fedik Using the following works:

{
      "package": "choices.js",
      "name": "choicesjs",
      "type": "style",
      "uri": "administrator/templates/xxxxxx/css/vendor/choicesjs/choices.min.css"
 },
{
      "package": "choices.js",
      "name": "choicesjs",
      "type": "preset",
      "dependencies": [
        "choicesjs#style",
        "choicesjs#script"
      ]
 }
avatar C-Lodder C-Lodder - change - 14 Nov 2019
Status New Closed
Closed_Date 0000-00-00 00:00:00 2019-11-14 12:10:12
Closed_By C-Lodder
avatar C-Lodder C-Lodder - close - 14 Nov 2019
avatar Fedik
Fedik - comment - 14 Nov 2019

@C-Lodder the uri can be simpler vendor/choicesjs/choices.min.css 😉

A bit more explanation.
WebAsset use HTMLHelper in next way:

  • if uri absolute, it does not search override:
    HTMLHelper::_('script', 'blabla.js', ['relative' => false])
  • if uri not absolute, it use it as relative to /media, and search for overrides:
    HTMLHelper::_('script', 'blabla.js', ['relative' => true])
avatar C-Lodder
C-Lodder - comment - 14 Nov 2019

ah nice, thanks :)

Add a Comment

Login with GitHub to post a comment