Want to put javascript inside prestashop template system that use smarty.
Solutions
In order to get javascript working inside .tpl file, you must put the javascript inside the {literal}{/literal} tags. example :
<script language="javascript">
{literal}
function DisplayVisits()
{
// How many visits so far?
var numVisits = GetCookie("numVisits");
if (numVisits) numVisits = parseInt(numVisits) + 1;
else numVisits = 1; // the value for the new cookie
// Show the number of visits
if (numVisits==1) document.write("This is your first visit.");
else document.write("You have visited this page " + numVisits + " times.");
// Set the cookie to expire 365 days from now
var today = new Date();
today.setTime(today.getTime() + 365 /*days*/ * 24 /*hours*/ * 60 /*minutes*/ * 60 /*seconds*/ * 1000 /*milliseconds*/);
SetCookie("numVisits", numVisits, today);
}
{/literal}
</script>