 |
Smarty
The discussions here are for Smarty, a template engine for the PHP programming language. Dedicated server web hosting provided by Guru-host.eu. |
| View previous topic :: View next topic |
| Author |
Message |
emanzipado Smarty n00b
Joined: 26 Apr 2012 Posts: 1
|
Posted: Thu Apr 26, 2012 11:31 am Post subject: Variable name depends on the value of another variable |
|
|
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 |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 4186 Location: Hamburg / Germany
|
Posted: Thu Apr 26, 2012 2:19 pm Post subject: |
|
|
You must first build the name of the config variable.
| Code: | {$bar = "var_{$foo->suffix}"}
{$smarty.config.$bar} |
|
|
| 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
|