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

Variable variables in a template

 
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
datenpunk
Smarty Rookie


Joined: 17 May 2003
Posts: 6

PostPosted: Fri Jun 27, 2003 11:25 pm    Post subject: Variable variables in a template Reply with quote

Hello,

is there a way to have dynamic variable names in smarty.

e.g.

1. assign $cLANG to 'EN'

template:
$ItemDescription_$cLANG

now I want smarty to output the value of
$ItemDescription_EN

I don't want to use if's for that and there is no way to make an array looking like $ItemDescription[$cLANG].

Any chance for me to solve this?

Thanks in advance

Daniel Khan
Back to top
View user's profile Send private message
bkatsma
Smarty n00b


Joined: 30 Jun 2003
Posts: 3

PostPosted: Mon Jun 30, 2003 3:57 pm    Post subject: Reply with quote

Try catinating it.


{$ItemDescription_|cat:"$cLANG}

And look here.
http://smarty.php.net/manual/en/language.modifier.cat.php
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Mon Jun 30, 2003 5:22 pm    Post subject: Reply with quote

@datenpunk: this is not easily possible, maybe only with some ugly custom plugins/modifiers.

you are best of using another format for your data, that suits better to smarty or do the conversion in php and not in smarty.

for example: if you don't have $ItemDescription_EN and $ItemDescription_DE etc. in php but instead
$ItemDescription['EN'] and $ItemDescription['DE'] etc.
then you can easily access them as $ItemDescription.$cLANG in smarty.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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