JHollowell Posted July 26, 2014 Share Posted July 26, 2014 I'm trying to place javascript just after the opening <body> tag in header.tpl. I am using {literal}{/literal} to surround the code. If I put anything, even a comment, inside the <script> tags they disappear when viewing source. PS v1.6.0.6. Example of what I am using and this doesn't even work: {literal} <script type="text/javascript"> // just a comment </script> {/literal} When I view source, I see nothing where the code should be. It's almost like there is a scrubbing function that removes any JS if in header.tpl. I've placed JS in footer.tpl and have no problems. ??? Thoughts ??? Link to comment Share on other sites More sharing options...
Bill Dalton Posted July 26, 2014 Share Posted July 26, 2014 Try it like this, <script type="text/javascript">{literal}Your Script ...{/literal}</script> Link to comment Share on other sites More sharing options...
vekia Posted July 27, 2014 Share Posted July 27, 2014 two things: 1) disable html purifier under preferences > general 2) under adv. parameters > performance untick option to move js scripts to "footer" section Link to comment Share on other sites More sharing options...
JHollowell Posted July 28, 2014 Author Share Posted July 28, 2014 Vekia, I don't see either of those options using 1.6.0.6. Link to comment Share on other sites More sharing options...
vekia Posted July 30, 2014 Share Posted July 30, 2014 sadly, options that i mentioned are a part of prestashop 1.6.0.8 and newest releases have you tried to disable all CCC / performance options under preferences > performance ? Link to comment Share on other sites More sharing options...
JHollowell Posted July 30, 2014 Author Share Posted July 30, 2014 Yes. Everything is disabled in CCC / performance options under preferences > performance Link to comment Share on other sites More sharing options...
JHollowell Posted August 6, 2014 Author Share Posted August 6, 2014 You can get some scripts to stay in the header with a few steps. The first is to perform an Media class override. https://gist.github.com/hereswhatidid/8c8edef106ee95138b03. Then you need to set a variable in the FrontOfficeController to send to the smarty template. In the header.tpl, an {if isset} wrapped around your script will place it into the header. Not a great solution, but works when you need to add Google Tag Manager data layers. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now