Hi,
I’m hoping this is an obvious question, with an easy answer. I have one template for my site, but some pages require javascript for things like LightBox. do I have to include these on every page, or is there a way to have them only included in the page when needed ?
Thanks,
Allen
Thanks for your suggestions.
I did some searching myself and came across the $mod->regClientStartupScript() and corresponding $mod->regClientCSS() functions. The way I now do this is to create a Snippet and use these function to load the required JS and CSS for the page. I can then add this snippet code to my page (created by my site template). This way I don’t need to hard-code any document IDs, or put any conditional logic in the page, I just add the Snippet to any page that needs it.
I’m being to enjoy MODx and appreciate the power of the application.
Allen