Smarty variable variables don't validate in template. Bug?

Help with getting the CMS CORE package up and running. This does not include 3rd party modules, PHP scripts, anything downloaded via module manager or from any external source.
Locked
User avatar
noosphere
Forum Members
Forum Members
Posts: 54
Joined: Tue Feb 26, 2008 9:20 am

Smarty variable variables don't validate in template. Bug?

Post by noosphere »

Hello,
I had variable variables in Smarty template with CMSMS 1.9 and worked fine.
After upgrading to 1.11 they're not accepted. The template would not vaildate. Then it randomly validated!
I pasted the full template's source in phpMyAdmin and it's fine.
But still the Apply button would not allow me to save changes.

This is the "bad" fully Smarty-valid code:

Code: Select all

{section name=loop start=1 loop=$created[nu].pcs}
{assign var = 'idx' value = "pc`$smarty.section.loop.index`"}
{$created[nu].$idx}
{/section}
Hope you can fix it ;-)
User avatar
frankmanl
Power Poster
Power Poster
Posts: 425
Joined: Sat Jul 12, 2008 3:50 am

Re: Smarty variable variables don't validate in template. Bu

Post by frankmanl »

Code: Select all

"pc`$smarty.section.loop.index`"
Not knowing much about SMARTY I'd say the ` is incorrect.
To me it looks strange to have single quotation marks within double quotation marks.
And most of all you should not use ` but '.
Jos
Support Guru
Support Guru
Posts: 4020
Joined: Wed Sep 05, 2007 8:03 pm

Re: Smarty variable variables don't validate in template. Bu

Post by Jos »

Did you upgrade to 1.11 or to 1.11.3

only in case of 1.11.3 you can read Stikki's post here http://forum.cmsmadesimple.org/viewtopi ... 64#p290164
fredp
Forum Members
Forum Members
Posts: 218
Joined: Sun Jul 27, 2008 1:36 am

Re: Smarty variable variables don't validate in template. Bu

Post by fredp »

frankmanl wrote:

Code: Select all

"pc`$smarty.section.loop.index`"
Not knowing much about SMARTY I'd say the ` is incorrect.
To me it looks strange to have single quotation marks within double quotation marks.
And most of all you should not use ` but '.
Hi,

Backticks are necessary if the variable name contains a period(.):
Online Smarty 3 docs wrote:Embedding Vars in Double Quotes
  1. Smarty will recognize assigned variables embedded in "double quotes" so long as the variable name contains only numbers, letters and under_scores. See naming for more detail.
  2. With any other characters, for example a period(.) or $object->reference, then the variable must be surrounded by `backticks`.
  3. In addition Smarty3 does allow embedded Smarty tags in double quoted strings. This is useful if you want to include variables with modifiers, plugin or PHP function results.
Nearly all men can stand adversity, but if you want to test a man's character, give him power.
- Abraham Lincoln
User avatar
noosphere
Forum Members
Forum Members
Posts: 54
Joined: Tue Feb 26, 2008 9:20 am

Re: Smarty variable variables don't validate in template. Bu

Post by noosphere »

Thank you for replying. It seems this issue is related to what Stikki's being working in SVN.
Yes, version is 1.11.3. I'll check new version asap.

Have a nice day all.

PS:
frankmanl wrote:

Code: Select all

"pc`$smarty.section.loop.index`"
Not knowing much about SMARTY I'd say the ` is incorrect.
This is for you then ;-)
http://www.smarty.net/docsv2/en/languag ... quotes.tpl
Locked

Return to “[locked] Installation, Setup and Upgrade”