Skip to the content
Documentation

tree is not a tree but a list

No ratings yet

Be aware that 'tree' doesn't return a tree, matrix of array of arrays but a list.
Making a sort on a 'tree' totaly destroys the tree structure and sort all the listed objects without taking in count there depth or parent node.If you wan't to search by depth and parent, it seems that you can't. No recursive function to step easily through this not-tree-but-list.

Comments (1 historical)

Written by readers of the earlier documentation sites, kept as they were.

  1. Re: tree is not a tree but a list

    Simon ·

    Each object is a tree.
    I used depth=1 and parse childs.
    Example :

    {def $tree_node = fetch('content', 'tree', hash( 'parent_node_id', $pagedata.root_node, 'depth', 1 ) ) }<ul>{foreach $tree_node as $key => $item}  <li{cond($key|eq(0), ' class="firstli"')}><a href={$item.url_alias|ezurl(no)}>{$item.name}</a>   <ul> {foreach $item.children as $subkey => $subitem}   <li{cond($subkey|eq(0), ' class="firstli"')}><a href={$subitem.url_alias|ezurl(no)}>{$subitem.name}</a></li> {/foreach}   </ul>  </li>{/foreach}</ul>