Joining Smarty variables in the template?
Posted: Sat May 19, 2007 2:32 am
Im using Smarty as a templating system for a project im currently working on.
In my php file, im assigning an integer to a variable, and passing that to a template. Then, in the template i want to add a prefix onto that number. Im then trying to use that to call a constant from the configuration file.
for example:
but it seems the only way i can get this to work is by assigning a variable in the template, then using that var to call the constant.
and yes, this works fine... i just dont like having to assign so many unnessicary variables just to call a value.
also, the only reason im not combining these on the script level is because the script is executed for several templates, and each template needs a different prefix, as they are calling different variables for the same id.
Its a simple concept, but i cant figure it out for the life of me. I've been scanning the documentation for a while now, and don't see anything that referrs to what Im looking for.
If anyone knows how to do this, I would greatly appreciate the help
In my php file, im assigning an integer to a variable, and passing that to a template. Then, in the template i want to add a prefix onto that number. Im then trying to use that to call a constant from the configuration file.
for example:
Code: Select all
{$smarty.config."id_`$data.result`"}Code: Select all
{assign var="idnum" value="id_`$data.result`"}
{$smarty.config.$idnum}also, the only reason im not combining these on the script level is because the script is executed for several templates, and each template needs a different prefix, as they are calling different variables for the same id.
Its a simple concept, but i cant figure it out for the life of me. I've been scanning the documentation for a while now, and don't see anything that referrs to what Im looking for.
If anyone knows how to do this, I would greatly appreciate the help