providesAsset for packages

Permalink 1 user found helpful
How does providesAsset work for packages?

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?

A3020
 
mnakalay replied on at Permalink Reply
mnakalay
Hello,
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.
siton replied on at Permalink Reply
siton
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...
mnakalay replied on at Permalink Reply
mnakalay
oh wow totally missed that. Please ignore my previous answer.

1000 years of shame on me...
A3020 replied on at Permalink Reply
A3020
That isn't working for packages (see my attempts above).
mnakalay replied on at Permalink Reply
mnakalay
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.
A3020 replied on at Permalink Reply
A3020
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.
mnakalay replied on at Permalink Reply
mnakalay
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.
mnakalay replied on at Permalink Best Answer Reply
mnakalay
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');
A3020 replied on at Permalink Reply
A3020
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');
mnakalay replied on at Permalink Reply
mnakalay
Wouldn't this mean that you are not loading any css whatsoever no matter where it came from?
A3020 replied on at Permalink Reply
A3020
Yeah, well, that the Theme would provide all the CSS (or JavaScript).