Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Dedicated server web hosting provided by Guru-host.eu.
Variable name depends on the value of another variable

 
Post new topic   Reply to topic    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
emanzipado
Smarty n00b


Joined: 26 Apr 2012
Posts: 1

PostPosted: Thu Apr 26, 2012 11:31 am    Post subject: Variable name depends on the value of another variable Reply with quote

Hello

I have the following problem. I have several variables defined in a config file that differ in a suffix.

var_01 = "hello"
var_02 = "world"
var_03 = "!"

In the Smarty template I have a variable value is the suffix of one of these variables $foo->suffix

I tried the following but not working:

{$smarty.config.var_{$foo->suffix}}

Do you understand my problem?

Greetings to all and thank you!
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 4186
Location: Hamburg / Germany

PostPosted: Thu Apr 26, 2012 2:19 pm    Post subject: Reply with quote

You must first build the name of the config variable.

Code:
{$bar = "var_{$foo->suffix}"}
{$smarty.config.$bar}
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    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