all code below is smarty2
All smarty variables are stored inside the $ smarty → _ tpl_vars object, so before retrieving () your template, you can:
$smarty->assign('magic_array_of_variables', $smarty->_tpl_vars);
Since this can be impractical, you can also write a small smarty plugin function that does something like this:
function smarty_function_magic_array_of_variables($params, &$smarty) { foreach($smarty->_tpl_vars as $key=>$value) { echo "$key is $value<br>"; } }
and from your tpl call it with:
{magic_array_of_variables}
Alternatively, in this function you can:
function smarty_function_magic_array_of_variables($params, &$smarty) { $smarty->_tpl_vars['magic_array_of_variables'] = $smarty->_tpl_vars; }
and in your template:
{magic_array_of_variables} {foreach from=$magic_array_of_variables key=varname item=varvalue} {$varname} is {$varvalue} {/foreach}
source share