Clean way to use JS and CSS from the packages folder
I'm making a package for concrete. My package has some JS files and a few CSS files that need to be added to the head of my website. Is there a way to include them in the head when you install the package? I know I can copy them manually to the right place, but I'm trying to make my package as self contained as possible, for an easy setup.
It's simple enough to include a php that contains the <link> and <script> elements i need, but the problem is they don't have a url in the packages folder... I suspect concrete protects access to the packages folder via url?
There are probably examples in some of the one of the boilerplate or starter packages in the marketplace. Also see my Load.UI addon.
To just add them to pages containing a block, you can use an on_block_load handler in the block controller. See my Ajax Lessons addon for examples of use with a block.
Here are my functions:
The best way to be independant of all that is to use the 2 - parameter version of the html helper.
If you put your js in
And similar for css in packages/packagename/css/
If you want to keep the css and js for a jquery plugin together, you can start a path ../js/ etc to track across the tree.
Because you are using nivo, it may also be worth adding the third namespace array parameter to the html helper methods. That will help prevent script collisions if other addons on the same page use their own copies of nivo.