Forums / Developer / Tree View / Comment62654

Author Topic

Thiago Campos Viana

Thursday 14 October 2010 10:06:37 am

Comment62654

The problem is that a tree is not a tree but a list, see the comments on tree fetch function documentation

You need to specify a depth of 1 and parse the children of each node:

{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>

eZ Publish Certified Developer: http://auth.ez.no/certification/verify/376924

Twitter: http://twitter.com/tcv_br