pdaalmeer Posted February 11, 2016 Share Posted February 11, 2016 (edited) Hello, I want to add some code to a Prestashop site, for a google translate button. Does anyone knows how i can add this code to the homepage? Just add the code above a page with the <> code on doesn't work. This is the code; <div id="google_translate_element"></div><script type="text/javascript"> function googleTranslateElementInit() { new google.translate.TranslateElement({pageLanguage: 'nl'}, 'google_translate_element'); } </script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script> Edited February 15, 2016 by pdaalmeer (see edit history) Link to comment Share on other sites More sharing options...
tuk66 Posted February 11, 2016 Share Posted February 11, 2016 { and } have to be enclosed by {literal} and {/literal} tags like: {literal} function googleTranslateElementInit() { new google.translate.TranslateElement({pageLanguage: 'nl'}, 'google_translate_element'); } {/literal} Link to comment Share on other sites More sharing options...
pdaalmeer Posted February 11, 2016 Author Share Posted February 11, 2016 thanks for the answer. Still something goes wrong, but i'm new with Prestashop. When i add the code in the CMS page i get an error "The field content is invalid." i add this in the editor CMS page ( using the source code </>) <div id="google_translate_element"></div> <script>// <![CDATA[ {literal} function googleTranslateElementInit() { new google.translate.TranslateElement({pageLanguage: 'nl'}, 'google_translate_element'); } {/literal} // ]]></script> <script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script> Link to comment Share on other sites More sharing options...
tuk66 Posted February 11, 2016 Share Posted February 11, 2016 You can't do it in a CMS page. JavaScript is not supported there. I wrote about .tpl templates. 1 Link to comment Share on other sites More sharing options...
pdaalmeer Posted February 11, 2016 Author Share Posted February 11, 2016 allright, Sorry, new stuff for me. can i add the text with an editor to some of the .tpl files? Is there an .tpl page for the homepage? And can i add the code above? 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