To get the values of previously assigned template variables in Smarty 3, use the getTemplateVars() method. When called without parameters, returns the entire array of assigned variables, and when specifying the variable name as a parameter, returns its value, respectively.
<?php $smarty->assign('foo', 'bar'); $foo = $smarty->getTemplateVars('foo'); $all_tpl_vars = $smarty->getTemplateVars();
For earlier versions ( Smarty 2.x ) get_template_vars()
$smarty = new Smarty; $smarty->assign('foo', 123); $foo = $smarty->get_template_vars('foo'); print_r($foo);
UPD
Since the question was revolved, the decision changes somewhat. The above code does not refer to the template, but php code. In the case of accessing a variable from a template inside the {php} tags, the code will be as follows:
{php} print_r($this->get_template_vars('foo')) {/php}
Naturally, the work is already going on inside smarti itself, since what should be addressed to $this .
Well, in general, the tag {php} excluded from Smarty3, because do not interfere with logic and representation, for it is bad.
$smarty->assign('categoryID, $catId). Or do you want to extract and modify a previously added variable? - terangetTemplateVars()- teran