|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
ekhnaton Smarty n00b
Joined: 26 Feb 2019 Posts: 1
|
Posted: Tue Feb 26, 2019 6:46 am Post subject: getTemplateVars() question |
|
|
Hi all,
I'm new to Smarty, sorry if my question is redundant in the forum. I checked through google for hours, could not find solution.
Step1: (PHP)
$smarty->assign('Name', 'Fred');
Step2: (PHP)
$smarty->display('the tpl file');
Step3: (in the tpl file)
{$Name = "Bob"}
Step4: (in the tpl file
{$Name}
shows "Bob"
Step5: (PHP, after the display)
echo $smarty->getTemplateVars('Name');
shows "Fred" again
So my question is, after altering a variant in Smarty, and display the tpl file, how to get the altered variant value to work with it further?
Thanks a lot. |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Tue Feb 26, 2019 9:07 am Post subject: |
|
|
You can't, nor should, do anything like that.
Template variables assigned in template are contained within specific template scope and do not alter variables assigned from code, or variables assigned earlier in parent templates' scopes.
$smarty->display(); should be the last action of your script, if you are doing anything after it, fix your broken code logic. |
|
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
|