Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

getTemplateVars() question

 
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 -> General
View previous topic :: View next topic  
Author Message
ekhnaton
Smarty n00b


Joined: 26 Feb 2019
Posts: 1

PostPosted: Tue Feb 26, 2019 6:46 am    Post subject: getTemplateVars() question Reply with quote

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
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Tue Feb 26, 2019 9:07 am    Post subject: Reply with quote

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
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 -> 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