Literal tags should be used to interpret your JavaScript in our Smarty environment. {literal} tags allow a block of data to be taken literally. This is typically used around Javascript or stylesheet blocks where {curly braces} would interfere with the template delimeter syntax. Anything within {literal}{/literal} tags are not interpreted but displayed as-is. 


Note: Pinnacle Cart uses Smarty templates engine to generate HTML pages. It requires some basic programming skills to edit these files. If you’re unfamiliar with HTML, we STRONGLY DISCOURAGE changing any code on your cart as these changes could disable some functions on your live site. Our customer support team cannot support you on any customizations or code changes you make to the application.


Surrounding Your JavaScript with Literal Tags


The shopping cart requires any JavaScript code to be surrounded by {literal} tags for the JavaScript to work. The {literal} tag tells the smarty engine to ignore any functions between the tags. 


To get the Smarty engine to treat curly brackets as part of your code and not a Smarty variable, you'll want to use what are called literal tags or {literal} {/literal} which are the open and close tags respectively. Ideally, you will wrap both tags around any curly bracket being used in your code. Most commonly, you will see these used inside of JavaScript chunks as curly brackets are used as part of the regular operators.


A working example of this would be as follows;


<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/
javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try
{literal}
{
{/literal}
var pageTracker = _gat._getTracker("UA-xxxxx-x");
pageTracker._trackPageview();
{literal}
}
{/literal}
catch(err)
{literal}
{
{/literal}{literal}
}
{/literal}
</script>


Notice how each curly brace {} is surrounded by a literal tag.


You also could have done it the following way, but it is considered to be less efficient;


{literal}
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/
javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-xxxxx-x");
pageTracker._trackPageview();
} catch(err) {}</script>
{/literal}


Links to Related Articles


How do I add JavaScript to my cart?


If you didn't get your question answered, please contact the Pinnacle Cart Support Team. To submit a ticket, go to the My Account drop-down menu at the top right of the admin area and select Support.