Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Template Questions /

Tree Menu


Go to End
Reply


9 Posts   4096 Views

Avatar
Jean-Phi

Community Member, 12 Posts

23 January 2009 at 10:33pm

Hi,

is there an easy way to build a tree menu like this :

<ul>
<li><a href="">Section 1</a>
<ul>
<li><a href="">Section 1.1</a></li>
<li><a href="">Section 1.2</a></li>
</ul>
</li>
<li><a href="">Section 2</a></li>
............
</ul>

from site tree content

Avatar
Nivanka

Community Member, 400 Posts

24 January 2009 at 3:17pm

yes this can be done,

use the following code

<ul>
<% control Menu(1) %>

<li><a href="$Link">$MenuTitle</a></li>

<% if Menu(2) %>
<ul>
<% control Menu(2) %>

<li><a href="$Link">$MenuTitle</a></li>
<% if Children %>
<ul>
<% control Children %>

<li><a href="$Link">$MenuTitle</a></li>

<% end_control %>
<ul>
<% end_if %>

<% end_control %>

</ul>

<% end_if %>

<% end_control %>
</ul>

Avatar
Jean-Phi

Community Member, 12 Posts

24 January 2009 at 10:23pm

Thanks, here is my working script :

<ul id ="navigation">
   <% control Menu(1) %>   
      <li class="$LinkingMode navigation_$iteratorPos"><a href="$Link" title="$Title.XML page" class="$LinkingMode">$MenuTitle.XML</a>
       <% if Children %>
<ul>
<% control Children %>
<li><a href="$Link">$MenuTitle</a></li>
<% end_control %>
</ul>
<% end_if %>
      </li>
   <% end_control %>
</ul>

Avatar
Nivanka

Community Member, 400 Posts

25 January 2009 at 1:55am

Good, I see your code only have two levels but mine has three levels ;)

Avatar
Jean-Phi

Community Member, 12 Posts

25 January 2009 at 1:59am

Yes :)

I think there's no way to build a recursive tree with .ss, isn't it?

while($children){....

Avatar
Antoine

Community Member, 3 Posts

10 September 2009 at 9:35am

Hi,

I am trying to do the same and to use ddsmoothmenu.
I would like to go as deep as the tree is.
But it seems to be impossible to call a template recursively, isn't it ?

Menu.ss

<ul>
<% control Menu(1) %>
<li>
<a href="$Link">$MenuTitle</a>
<% include _Menu %>
</li>
<% end_control %>
</ul>

_Menu.ss

<% if Children %>
<ul>
<% control Children %>
<li>
<a href="$Link">$MenuTitle</a>
<% include _Menu %>
</li>
<% end_control %>
</ul>
<% end_if %>

<% include _Menu %> in _Menu.ss does not work.
And what if IK would like to pass an argument like the level ?
<% include _Menu(level++) %>

Thanks

Avatar
Antoine

Community Member, 3 Posts

17 October 2009 at 8:36pm

I have released a simple module - ssdropdownmenu - to do that

Avatar
Nivanka

Community Member, 400 Posts

18 October 2009 at 6:42pm

where can i find the code please?

Go to Top