Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Variables syntax

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks
View previous topic :: View next topic  
Author Message
babo
Smarty n00b


Joined: 29 May 2005
Posts: 2

PostPosted: Mon May 30, 2005 5:48 pm    Post subject: Variables syntax Reply with quote

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
View user's profile Send private message
babo
Smarty n00b


Joined: 29 May 2005
Posts: 2

PostPosted: Mon May 30, 2005 6:06 pm    Post subject: Reply with quote

{assign var=tmp value=prefix_$id}
{if $var.$tmp} - work.

Any others variants, without assign?
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Mon May 30, 2005 6:10 pm    Post subject: Reply with quote

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
View user's profile Send private message
topless98gt
Smarty Rookie


Joined: 10 Jul 2005
Posts: 17
Location: Arlington, TX

PostPosted: Mon Jul 11, 2005 6:39 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Mon Jul 11, 2005 6:51 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP