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

inserting vars as part of the name of another var

 
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 -> General
View previous topic :: View next topic  
Author Message
Squee-D
Smarty n00b


Joined: 24 Jun 2003
Posts: 4
Location: Waipu, New Zealand

PostPosted: Tue Jul 15, 2003 11:17 am    Post subject: inserting vars as part of the name of another var Reply with quote

I have a question or two, perhaps this belongs in a faq?

1. if i want to reference an associative array key using a smarty template, how would I do that?

eg: {$my_assoc_array.$some.ref}

so if $some.ref == "item"

then I would get the result as if i entered {$my_assoc_array.item}

2. Similarily, if I want to use one var to substitute part of the name of another variable, how would I do that?

eg: {$my_`$inject.name'_bar}

so if $inject.name == 'foo'

i would really be asking for {$my_foo_bar}


Notice in both cases my 'injected' variable is actually an object, to complicate things just a little Smile
_________________
Yours,
Rasheed Abdal-Aziz
System Architect
Simtrek P/L
rasheed@simtrek.com
Back to top
View user's profile Send private message Visit poster's website
boots
Administrator


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

PostPosted: Wed Jul 16, 2003 9:05 am    Post subject: Reply with quote

1. http://www.phpinsider.com/smarty-forum/viewtopic.php?t=320

2. is an excercise for the reader Wink. It occurs to me that there may be a straightforward answer for this but I'm obviously too tired to think of it--all that is coming to me at the moment are methods too cumbersome to mention.
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 -> General 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