eZ Community » Forums » General » 4.7: JS for single page?
expandshrink

4.7: JS for single page?

4.7: JS for single page?

Monday 18 May 2015 1:39:09 pm - 1 reply

How can I add Javascript only for one single page?

Monday 18 May 2015 2:22:00 pm

Hello Jyrgen,

Welcome to the eZ Community!

The short answer is YES! I do this myself quite regularly for customer projects.

You can use the 'ezscript_require' operator to include a javascript file only on a specific template which is used on a specific page.

Technical details to study and learn from:

https://github.com/ezsystems/ezpublish-legacy/blob/master/extension/ezjscore/autoloads/eztemplateautoload.php#L20

https://github.com/ezsystems/ezpublish-legacy/blob/master/extension/ezjscore/autoloads/ezjscpackertemplatefunctions.php#L31

https://github.com/ezsystems/ezpublish-legacy/blob/master/extension/ezjscore/doc/INSTALL#L102

https://github.com/ezsystems/ezpublish-legacy/blob/master/extension/ezjscore/doc/FAQ

https://github.com/ezsystems/ezpublish-legacy/blob/master/settings/design.ini#L38

Educational article on how to use ezjscore and ezscript_require operator:

http://share.ez.no/learn/ez-publish/ezjscore-ez-publish-javascript-and-ajax-framework

I hope this helps!

Cheers,
Heath

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from