When to use {literal} tag?
Posted: Wed Oct 07, 2009 10:49 pm
Yep, I know, there are numerous previous threads about the same topic. However, things that happended when I added a couple of banners (via javascript) got me really confused, so please help me to get this sorted out once and for all.
I use the latest version (1.6.6) and attempted to add external javascripts through global content blocks without using the {literal} tag, one of the javascript banners had this format:
var uri = 'http://impse.tradedoubler.com/imp?type( ... a(1234567)' + new String (Math.random()).substring (2, 11);
document.write('');
So what happened when I loaded the page after adding this code?
Well, except for getting error messages like this at the very top:
string(120) "Smarty error: [in tpl_body:23 line 10]: syntax error: invalid attribute name: '=' (Smarty_Compiler.class.php, line 1550)" string(153) "Smarty error: [in tpl_body:23 line 10]: syntax error: invalid attribute name: 'Grs1HHKznjUZN4KIq8jPnNRwAMd"start"' (Smarty_Compiler.class.php, line 1550)"
CMSMS also changed code in the menu manager and template!! I noticed that $node->url got something that looked like a hash added which prevented any links to work. A strange observation was that after reloading the page, the Smarty error message disappeared, until a new javascript was added and so on.
The reason I didn't use the {literal} tag was because I thought that it only is needed if the actual included code contains {} chars, which the above example doesn't. I think it would be weird to get Smarty errors since the javascript is runned at the client, not at the web server. However, the problem seems to have disappeared after enclosing the javascripts within {literal}. Adding to the mystery, I've included other javascript code without using {literal} on other CMSMS installations without any issues.
Please, once and for all, explain to me if and why I need to use the {literal} tag when adding code that doesn't include any {} chars.
Also, if you have some explanation for the mentioned spooky behavior that occured after loading the javascript without {literal} tags, I would be very thankful.
I use the latest version (1.6.6) and attempted to add external javascripts through global content blocks without using the {literal} tag, one of the javascript banners had this format:
var uri = 'http://impse.tradedoubler.com/imp?type( ... a(1234567)' + new String (Math.random()).substring (2, 11);
document.write('');
So what happened when I loaded the page after adding this code?
Well, except for getting error messages like this at the very top:
string(120) "Smarty error: [in tpl_body:23 line 10]: syntax error: invalid attribute name: '=' (Smarty_Compiler.class.php, line 1550)" string(153) "Smarty error: [in tpl_body:23 line 10]: syntax error: invalid attribute name: 'Grs1HHKznjUZN4KIq8jPnNRwAMd"start"' (Smarty_Compiler.class.php, line 1550)"
CMSMS also changed code in the menu manager and template!! I noticed that $node->url got something that looked like a hash added which prevented any links to work. A strange observation was that after reloading the page, the Smarty error message disappeared, until a new javascript was added and so on.
The reason I didn't use the {literal} tag was because I thought that it only is needed if the actual included code contains {} chars, which the above example doesn't. I think it would be weird to get Smarty errors since the javascript is runned at the client, not at the web server. However, the problem seems to have disappeared after enclosing the javascripts within {literal}. Adding to the mystery, I've included other javascript code without using {literal} on other CMSMS installations without any issues.
Please, once and for all, explain to me if and why I need to use the {literal} tag when adding code that doesn't include any {} chars.
Also, if you have some explanation for the mentioned spooky behavior that occured after loading the javascript without {literal} tags, I would be very thankful.