I have a block that needs to add 2 separate JS files. I first just made a "js" folder in my block files and it got included automatically. Problem is now, that Concrete5 includes one of these (jquery.ui.widget.js) already when logged in (or when the toolbar appears, I'm not sure. I will have users that cannot see the toolbar).
And if it's loaded twice it creates errors.
How do I load it best just once? So it loads when concrete5 doesn't load it and otherwise ignores it.
Should I check for logged in users or a toolbar appearance or could I add it with $this->addHeaderItem in a way that concrete5 recognizes that it includes the same file twice... which it obviously doesn't recognize when load trough the JS folder.
First you register the asset (js)
Then you add it to a group
and where you need it (in your block), you require it
concrete5 will handle it, and will only load it once,
There is quite a bit of documentation available about this.
Guess it's that:
I'll check it out.
But all I get is an Fatal error:
Class 'Concrete\Core\Asset\Asset' not found in /home/httpd/vhosts/xxx.com/httpdocs/application/config/app.php on line 12
...and a bugreport from April with exactly my problem:
Does that mean it's non-functional yet? Is anyone actually using this?
I did use the approach described in the docs.
I can give you a link to a blog with something I'm doing right now:
Forget about the overriding bits, but maybe there is something in it to help you.
Seems that I can use "H" and "F" instead of Asset:: that works so far. Also I need to call the assets in the page_theme.php and not in the block controller. Used in the page_theme it all works, but no matter what I try in the block controller, the script just doesn't show up, even though the block is loaded.
Guess I just use the page_theme.php for now.