Reputation: 209
I would like to know how to add JS inline in the of my website by the PHP file of my module. I tried the method "addJS" from the main controler but it seems that this is only works for importing external JS file.
Do you know how I can do to add my script in the head from the "hookDisplayRightColumn" function ?
Thank you in advance for your help and have a nice day!
Mickaël
Upvotes: 1
Views: 2132
Reputation: 3211
Short answer: you can't. If you need to add something to header, then you need to call hookDisplayHeader
.
I assume that you want to add some variables for your script; For that puropose I can suggest Media:addJsDef()
and $this->context->controller->addJS()
. Howeverm Media:addJsDef()
is only avaiable on PrestaShop 1.6 or later; If you need to define some JS variables in your page on PrestaShop 1.5 or lower, you indeed need to use hookDisplayHeader
.
EDIT: You may also try to insert your script using hookDisplayRightColumn and then write a block of script to header (not sure if that would work though, also very bad practice).
Upvotes: 1