|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
babo Smarty n00b
Joined: 29 May 2005 Posts: 2
|
Posted: Mon May 30, 2005 5:48 pm Post subject: Variables syntax |
|
|
How to write this?
$var['prefix_1'] = true;
$id = 1;
{if $var.prefix_$id} - not work.
Last edited by babo on Mon May 30, 2005 6:06 pm; edited 1 time in total |
|
Back to top |
|
babo Smarty n00b
Joined: 29 May 2005 Posts: 2
|
Posted: Mon May 30, 2005 6:06 pm Post subject: |
|
|
{assign var=tmp value=prefix_$id}
{if $var.$tmp} - work.
Any others variants, without assign? |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Mon May 30, 2005 6:10 pm Post subject: |
|
|
No. Consider using an array instead.
{$var.prefix.$id}
where "prefix" holds all of the prefix_$id styled vars (which are now named just by $id) |
|
Back to top |
|
topless98gt Smarty Rookie
Joined: 10 Jul 2005 Posts: 17 Location: Arlington, TX
|
Posted: Mon Jul 11, 2005 6:39 pm Post subject: |
|
|
If Smarty supports variable variables, then you can do it with $$. Otherwise, use arrays. _________________ Proud to be a Texan
Using Smarty 2.6.9 |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Mon Jul 11, 2005 6:51 pm Post subject: |
|
|
topless98gt wrote: | If Smarty supports variable variables, then you can do it with $$. |
It doesn't. Arrays are the way to go. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|