Tree
As of March 2017, Branch Code is deprecated and no longer developed. Use the Twig syntax instead.
Creates a recursive function to navigate through a tree of data.
Perhaps the best example is the default code used to build a navigation menu template. In fact, that is where the original name for this language construct came from. By default a navigation menu is built with a nested unordered list. The Tree construct allows a developer to recursively build a list of data. The "tree" name comes from the idea that each sub item array is a branch off of the parent item and each sub item within the sub item array is a leaf off of that branch.
Below is the basic construct of the Tree code.
{tree leaves="#items" branches="subItems"}
<ul>
{leaf}
<li>{ #leaf.name }{branch}</li>
{/leaf}
</ul>
{/tree}
Below is a real world example of setting up a navigation menu with multiple levels.
<ul{#menu.class}{#menu.id}>
{loop items="#items" value="item"}
<li{#item.link.class}>{#item.linkTag}{#item.divider}
{if #item.subItems}
{tree leaves="#item.subItems" branches="subItems"}
<ul>
{leaf}
<li{#leaf.link.class}>{#leaf.linkTag}{#leaf.divider}{branch}</li>
{/leaf}
</ul>
{/tree}
{/if}
</li>
{/loop}
</ul>