|
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 |
VsOK Smarty n00b
Joined: 20 Dec 2020 Posts: 2
|
Posted: Fri Dec 25, 2020 6:08 pm Post subject: How to pass a variable from smarty {$smarty} to php $smart? |
|
|
Как переменную из Smarty {$smarty}передать в php $smarty
How to pass a variable from smarty {$smarty} to php $smarty |
|
Back to top |
|
bsmither Smarty Elite
Joined: 20 Dec 2011 Posts: 322 Location: West Coast
|
Posted: Fri Dec 25, 2020 6:54 pm Post subject: |
|
|
Once Smarty is assigned a value for a variable, the PHP can learn what it is by using getTemplateVars('NAME').
Code: | $Smarty->assign('VAR',"value");
$foobar = $Smarty->getTemplateVars('VAR'); // $foobar equals "value" |
However, when Smarty is compiling a template, any values computed at that point is probably not available. This will probably not work (have not tested): Code: |
template.tpl:
{assign $VAR "value"}
PHP:
$output = $Smarty->fetch('template.tpl');
$foobar = $Smarty->getTemplateVars('VAR'); // $foobar is probably empty |
|
|
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
|