I am creating a plugin that returns a array to the template file. I can’t seem to get the full array to be parsed to the template file.
plugin function.arraytest
function smarty_function_arraytest($params,Smarty_Internal_Template $template)
{
$x = array("1"=>array("categories"=>"Action"));
return $x
}
template file
{arraytest}
result
array
I cannot seem to iterate through the array in the template file.
Any help would be very much appreciated.
Thanks
Anything returned by a smarty function gets output directly, the .tpl never actually gets the array, just the string value “Array”. It has been a long time since I used Smarty so this may have changed, but I believe the standard way of doing it is like this:
then call it like:
of course, because you have a multidimensional array you’ll need to loop over it twice: