Search the Knowledgebase |
Browse by Category |
|
|
|
Using javascript and curly brackets in Product Review templates |
Article Details
Last Updated 17th of January, 2011
|
User Opinions (5 votes) |
100%
0%
|
Thank you for rating this answer.
|
The Product Review Module admin interface gives you the ability to edit many of the module templates using the Smarty™ Template system:
Smarty uses special tags between curly brackets {} to represent values returned by the PHP script. As a result, Javascript or CSS you place inside of your template can cause your pages to break if it also contains curly brackets since the Smarty template parser will misinterpret the javascript or CSS code as template tags and generate an error.
There are a couple of workarounds for this issue:
1. Use the Smarty {ldelim} and {rdelim} tags in place of your curly brackets, for example:
<script type="text/javascript">
function showText(){
alert("Testing 1, 2, 3");
}
</script>
would become:
<script type="text/javascript">
function showText(){ldelim}
alert("Testing 1, 2, 3");
{rdelim}
</script>
2. Use the Smarty {literal} and {/literal} tags to escape an entire block of code that may contain curly brackets, for example:
<script type="text/javascript">
function showText(){
alert("Testing ");
for(n=0; n<3; n++){
alert(n + ' ');
}
}
</script>
would become:
{literal}
<script type="text/javascript">
<script type="text/javascript">
function showText(){
alert("Testing ");
for(n=0; n<3; n++){
alert(n + ' ');
}
}
</script>
{/literal}
|
Attachments |
No attachments were found.
|