0
在我看来,我得到所有页面
我得到我所有的页面以及所有的子项和子项。如何获得树状结构如下图所示:如何动态构建树状结构
<% for page in @pages%>
<li id="<%= page.id%>_page">
<div class="link">
#my attributes for the div<
/div>
#here I got the all siblings of that page. But here the structure is of just two
#levels. I need upto n-levels.
<% @childs = page.*descendants* %>
<% if [email protected]? && [email protected]? %>
<% for child in @childs%>
<ol class="child">
<li id="<%= child.id%>_page">
<div class="link">
#my attributes for the div
</div>
</li>
</ol>
<%end%>
<%end%>
</li>
<%end%>
我使用嵌套集,并希望这样的结构:
page1
page 2
page 3
page 3.1
page 3.2
page3.4
...so on to last child
page 4
page 5
....so on to N-levels...
尝试..我得到了解决之后...我呈现局部而这又使itself..such为 – Milind 2012-08-02 09:47:56