Yesterday I ran into a problem. I have an array, like:
1 => array (
'title' => 'title 1',
'sub' => array (
2 => array (
'title' => name 2 ',
'sub' => array (
3 => array (
'title' => 'title 3'
)
)
)
)
);
Processing it with smarty means turned out to be none - it does not support infinite loops inside any function. At the PHP level, this is not a problem to do - you just need to run the entire array through one output function, in which, when the sub-elements are found, make the same function call again, only with the array of sub-elements and then by analogy.
')
Can anyone implement the output of such tree arrays using smarti? :)
Update: Look at the option I found on some forum.It is done through a separate tree template.
{if $ tree}
{foreach from = $ tree item = "item"}
{$ item}
{if $ item.subtree}
{include file = "tree.tpl" tree = $ item.subcategories}
{/ if}
{/ foreach}
{/ if}
In the main template it is called like this:
{include file = "tree.tpl" tree = $ tree}
$ tree - This is an array with a tree structure.
taken
from here