Page 1 of 1

[solved] How to deal with {} sign that are not meant to be CMSMS tags

Posted: Tue Dec 02, 2008 9:45 pm
by Apprentice
Hello,

I'm having a problem installing JavaScipt to webpages using CMSMS. The script doesn't work and I think it is because CMSMS interprets {} signs in this code wrongly (its working fine outside CMSMS, although directory paths are bit different):

                   



Shadowbox.loadSkin('classic', 'uploads/js/src/skin');
Shadowbox.loadLanguage('en', 'uploads/js/src/lang');
Shadowbox.loadPlayer(['flv', 'html', 'iframe', 'img', 'qt', 'swf', 'wmp'], 'uploads/js/src/player');

window.onload = function(){
                    Shadowbox.init();
};


How can I get this working? Are [] signs in the code ok?

Thanks already.

Re: How to deal with {} sign that are not meant to be CMSMS tags

Posted: Tue Dec 02, 2008 9:54 pm
by reneh
the Smarty get confused if you include {} in the content!
This is fundamental Smarty knowledge:
Suround your scripts that include {}  with literal tags like this: {literal} {your code} {/literal}

Re: How to deal with {} sign that are not meant to be CMSMS tags

Posted: Tue Dec 02, 2008 9:58 pm
by benjamin72070
From the Smarty docs page:
Escaping Smarty Parsing

It is sometimes desirable or even necessary to have Smarty ignore sections it would otherwise parse. A classic example is embedding Javascript or CSS code in a template. The problem arises as those languages use the { and } characters which are also the default delimiters for Smarty.

The simplest thing is to avoid the situation altogether by separating your Javascript and CSS code into their own files and then using standard HTML methods to access them.

Including literal content is possible using {literal}..{/literal} blocks. Similar to HTML entity usage, you can use {ldelim},{rdelim} or {$smarty.ldelim} to display the current delimiters.

It is often convenient to simply change Smarty's $left_delimiter and $right_delimiter.
Regards,

Ben  ;D

Re: [solved] How to deal with {} sign that are not meant to be CMSMS tags

Posted: Fri Jan 30, 2009 11:38 am
by Hannibal
Exellent, this was exactly what I was looking for!  8)

Should have thought of the {literal} tags.