【发布时间】:2019-09-11 04:24:45
【问题描述】:
我正在尝试生成站点树中所有页面的嵌套菜单。
docs 显示两个级别 - 我不知道有多少级别。
目前我知道在某一点上至少有四个层次,所以我有这个:
<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>
它有效但不可靠(如果编辑器添加了另一个级别)。这很笨拙。有递归选项吗?
【问题讨论】:
标签: silverstripe silverstripe-4