Výpis hierarchického menu z výčtových zdrojů

Verze výpisu menu s omezením hloubky zanoření.

Aktuální hloubka zanoření je hodnotou parametru current_depth; s každým rekurzivním voláním se zvětšuje o jedna.

Fragmenty kódu

Defaultní režim šablony
<ul>
{while _template.root_menu}
  {_template mode="node" node=_.asset current_depth=1}
{/while}
</ul>
Režim "node"
<li>
  <a href="{value(target(node), link(node)}">{node.title}</a>
  {if (current_depth lt 3) and isParent(node, _primary)}
    {while node.menu}
    {whilefirst}<ul>{/whilefirst}
      {_template mode="node" node=_.asset current_depth=sum(current_depth, 1)}
    {whilelast}</ul>{/whilelast}
    {/while}
  {/if}
</li>