I am trying to generate a nested menu of all the pages in the site tree.
The docs show two levels - I won't know how many levels there are.
Currently I know there is at least four levels deep at one point so I have this:
<ul>
<% loop $Menu(1) %>
<li>
<a href="$Link" title="Go to the $Title page" class="<% if $isCurrent %>current<% else_if $isSection %>section<% end_if %>">
$MenuTitle
</a>
<% if $Children %>
<ul>
<% loop $Children %>
<li class="<% if $isCurrent %>current<% else_if $isSection %>section<% end_if %>">
<a href="$Link">$MenuTitle</a>
<% if $Children %>
<ul>
<% loop $Children %>
<li class="<% if $isCurrent %>current<% else_if $isSection %>section<% end_if %>">
<a href="$Link">$MenuTitle</a>
<% if $Children %>
<ul>
<% loop $Children %>
<li class="<% if $isCurrent %>current<% else_if $isSection %>section<% end_if %>">
<a href="$Link">$MenuTitle</a>
</li>
<% end_loop %>
</ul>
<% end_if %>
</li>
<% end_loop %>
</ul>
<% end_if %>
</li>
<% end_loop %>
</ul>
<% end_if %>
</li>
<% end_loop %>
</ul>
It works but is unreliable (if an editor adds another level). It is pretty janky. Is there a recursive option?