我在木兰Categories app中有一个类别树。
如何显示树中所有类别的无序列表?例如:
<ul>
<li>Cat</li>
<ul>
<li>Kitten</li>
</ul>
<li>Dog</li>
<ul>
<li>Puppy</li>
</ul>
<li>Fish</li>
<ul>
<li>Fry</li>
</ul>
</ul>
答案 0 :(得分:0)
编写一个遍历节点的递归宏。例如:
[#assign categoryRoot = cmsfn.contentByPath("/pet", "category")!]
[#assign children = cmsfn.children(categoryRoot)]
[@displayChildren children=children /]
[#macro displayChildren children]
<ul>
[#list children as child]
[#if child.@nodeType.name == "mgnl:category"]
<li>${child.displayName!}</li>
[#assign nestedChildren = cmsfn.children(child)!]
[#if nestedChildren?has_content]
[@displayChildren children=nestedChildren /]
[/#if]
[/#if]
[/#list]
</ul>
[/#macro]