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 in variable value

 
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 -> Tips and Tricks
View previous topic :: View next topic  
Author Message
shivgoa
Smarty n00b


Joined: 02 Dec 2012
Posts: 1

PostPosted: Sun Dec 02, 2012 10:20 am    Post subject: Variable in variable value Reply with quote

Suppose I have in php file
<?
$tpl->assign('_YEAR',date('Y'));
$tpl->assign('_FOOTER',"This is {$_YEAR}");
?>
and in templeate file
<div class="footer">{$_FOOTER}</div>
---
The current output is
<div class="footer">This is {$_YEAR}</div>
What do I do so that I get
<div class="footer">This is 2012</div>
----
P.S. Year is just an example. This can be any value coming from database.

Please help!
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Sun Dec 02, 2012 1:29 pm    Post subject: Reply with quote

Smarty does not parse assigned variable values for template code.
If you really need it see {eval} http://www.smarty.net/docs/en/language.function.eval.tpl

But this has very bad performance as the compiler must be called for each such variable.
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 -> Tips and Tricks 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