providesAsset for packages
Permalink 1 user found helpful
How does providesAsset work for packages?
I've tried these variations, but none of them works:
The package asset I want to exclude is a view.css which is automatically loaded.
Ideas?
I've tried these variations, but none of them works:
$this->providesAsset('css'); $this->providesAsset('css', 'package_handle/blocks/block_handle/*'); $this->providesAsset('css', 'package_handle/blocks/block_handle/view.css'); $this->providesAsset('css', 'blocks/block_handle/*'); $this->providesAsset('css', 'blocks/block_handle/view.css');
The package asset I want to exclude is a view.css which is automatically loaded.
Ideas?
Answer to you Question:
C5 docs (little scroll): "Disabling Inclusion of view.js or view.css at the Theme Level":
http://documentation.concrete5.org/developers/working-with-blocks/w...
General issue:
C5 docs: Automatically including CSS and JavaScript in Custom Templates:
http://documentation.concrete5.org/developers/working-with-blocks/w...
C5 docs (little scroll): "Disabling Inclusion of view.js or view.css at the Theme Level":
http://documentation.concrete5.org/developers/working-with-blocks/w...
General issue:
C5 docs: Automatically including CSS and JavaScript in Custom Templates:
http://documentation.concrete5.org/developers/working-with-blocks/w...
oh wow totally missed that. Please ignore my previous answer.
1000 years of shame on me...
1000 years of shame on me...
That isn't working for packages (see my attempts above).
Like the docs say, it needs to be done at the theme level. You might be able to override the page_theme file from a package.
A small misunderstanding here. Sorry for the trouble. What I meant in my initial post was:
How can I use providesAsset in page_theme.php (in application/theme dir) for assets that are loaded by packages? Because the providesAsset works fine for application block and core block assets, but not for package block assets.
How can I use providesAsset in page_theme.php (in application/theme dir) for assets that are loaded by packages? Because the providesAsset works fine for application block and core block assets, but not for package block assets.
Like the docs say, it needs to be done at the theme level. You might be able to override the page_theme file from a package.
I used this and it stopped view.css from loading on a non-core block that came in a package
$this->providesAsset('css', 'blocks/block_handle');
Hey that seems to work. Apparently those wildcard don't work. Hm, I'm sure I've seen that somewhere. Thanks for the fix.
Do you have any idea btw why this won't work?
$this->providesAsset('css');
In the ResponseAssetGroup class this would come down to:
$this->providedAssetGroup->addGroup('css');
Do you have any idea btw why this won't work?
$this->providesAsset('css');
In the ResponseAssetGroup class this would come down to:
$this->providedAssetGroup->addGroup('css');
Wouldn't this mean that you are not loading any css whatsoever no matter where it came from?
Yeah, well, that the Theme would provide all the CSS (or JavaScript).
the providesAsset function works to tell C5 that you are already providing something C5 is also providing but that you'd rather load it yourself.
It relies on the label attached to the resource to recognize it.
a view.css file is specific to a package's block for instance and is too generic to be controlled that way as far as I know.
The only way I know to not load view.css is to rename it.
Another way (not tested) might be to use a template that just uses the default view.php but doesn't include a view.css.
In theory (again not tested) the original view.css shouldn't load.