Aalaa Posted May 3, 2013 Share Posted May 3, 2013 I've been trying to add a script to a CMS page and it doesn't appear. I tried using the literal tag as suggested by previous posts, that didn't work as well. I also tried editing the pages from the source but I couldn't find location of the files. Is it possible there is a way to use scripts on CMS pages? Thank you! Link to comment Share on other sites More sharing options...
vekia Posted May 3, 2013 Share Posted May 3, 2013 1. where you exactly add {literal} tags? 2. what prestashop version you use? you can add script to the: themes / your_theme / cms.tpl this is template file for CMS pages. 2 Link to comment Share on other sites More sharing options...
Aalaa Posted May 3, 2013 Author Share Posted May 3, 2013 1. I put the script between the literal tags. 2. I'm using prestashop version 1.5.3.1 But doesn't the template file change all the CMS pages? I only need to add the script to one specific page. Thanks! Link to comment Share on other sites More sharing options...
vekia Posted May 3, 2013 Share Posted May 3, 2013 1. where exactly, by this i mean what file you changed? (literal tags doesnt work in editor in preferences -> CMS) you can add simple {if} condition where you can check id of the CMS page. i mean: {if $cms->id==1} {literal} SCRIPT CODE HERE {/literal} {/if} $cms->id==1 1 is an ID of the cms page for which you want to include script. you can get ID of cms page in preferences -> CMS 3 1 Link to comment Share on other sites More sharing options...
Aalaa Posted May 4, 2013 Author Share Posted May 4, 2013 I used the literal tags in the CMS page editor. I just tried your code in the same editor it doesn't work. Should I use it somewhere else? Sorry I'm a newbie I guess I'll figure it out sooner or later. Thanks. Link to comment Share on other sites More sharing options...
vekia Posted May 4, 2013 Share Posted May 4, 2013 I used the literal tags in the CMS page editor. I just tried your code in the same editor it doesn't work. Should I use it somewhere else? Sorry I'm a newbie I guess I'll figure it out sooner or later. Thanks. you don't have to use it in editor. 1. where exactly, by this i mean what file you changed? (literal tags doesnt work in editor in preferences -> CMS) you have to edit cms.tpl file located in your theme directory. Link to comment Share on other sites More sharing options...
amwaykem Posted January 23, 2015 Share Posted January 23, 2015 1. where exactly, by this i mean what file you changed? (literal tags doesnt work in editor in preferences -> CMS) you can add simple {if} condition where you can check id of the CMS page. i mean: {if $cms->id==1} {literal} SCRIPT CODE HERE {/literal} {/if} $cms->id==1 1 is an ID of the cms page for which you want to include script. you can get ID of cms page in preferences -> CMS Thx, it works!!)) 1 Link to comment Share on other sites More sharing options...
ZiZuu Posted January 30, 2015 Share Posted January 30, 2015 a little tricky .. but it works Link to comment Share on other sites More sharing options...
ItByBart Posted February 19, 2015 Share Posted February 19, 2015 Yes , it works. But why does it work in PS 1.4 and not in PS 1.6. Is this the official way or ...... Link to comment Share on other sites More sharing options...
parthaxms Posted April 10, 2015 Share Posted April 10, 2015 Don't know if it is the correct way or the wrong but It worked. Here how I did it. Added literal at the below of the cms.tpl {if $cms->id==3} {literal} <script type="text/javascript" src="mycustom.js"></script> {/literal} {/if} then put the mycustom.js file in the directory /themes/mytheme/js/autoload I am on 1.6 Link to comment Share on other sites More sharing options...
maxclee Posted September 21, 2016 Share Posted September 21, 2016 Hello I try this method but somehow doesn't work for me 100% <div class="rte{if $content_only} content_only{/if}"> {$cms->content} {if $cms->id==46} <div style="padding:50px;" id="zurmoExternalWebForm"> FORM {literal} <script type="text/javascript" src="http://myweb.com/go/app/index.php/contacts/external/sourceFiles?id=1"></script> {/literal} </div> {/if} </div> Appear div with text "FORM" but javascript doesn't work. some ideas ? Link to comment Share on other sites More sharing options...
colives Posted November 22, 2017 Share Posted November 22, 2017 Sorry for the silly question but, where is cms.tpl in PS7??????? Thanks!! Link to comment Share on other sites More sharing options...
Nishith Nesdiya Posted November 24, 2017 Share Posted November 24, 2017 On 11/23/2017 at 1:10 AM, colives said: Sorry for the silly question but, where is cms.tpl in PS7??????? Thanks!! Hi..in Prestashop 1.7 .xx not a cms.tpl file you can put your code here themes/your_themes/templates/cms/page.tpl Thanks Link to comment Share on other sites More sharing options...
kullraith Posted July 19, 2019 Share Posted July 19, 2019 (edited) Hello, in 1.6.1.1 this method puts the script below footer. at the end of cms.tpl {if $cms->id==10} {literal} <script src="https://www.cetelem.es/contenidos/ecommerce/info.js?partner=*****" charset="UTF-8" type="text/javascript"></script> {/literal} {/if} Edited July 19, 2019 by kullraith (see edit history) Link to comment Share on other sites More sharing options...
Lukas Truninger Posted August 25, 2019 Share Posted August 25, 2019 Hello, I'm dealing with the same issue. However, my scripts also depend on selected storefront language. Can I simply add an if condition to select the correct script? What's the correct syntax? Thanx Lukas 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