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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

menu control


Reply

3 Posts   760 Views

Avatar
s_a_m_y

10 March 2011 at 11:27pm Community Member, 25 Posts

Hi to all,

I have completed my first SilverStripe project and must say, I love the way it works. I am now starting my second approach which is a bit less standard. So I hope to get some help in how to go for this one. The problem is as follows:

The menu level1 is horizontal. No troubles so far. It includes eight categories. My problem now is, that the submenus of the first three categories should behave differently than the rest. How do I address those single categories, so I can manage this via an if-else construction?

Samy

Avatar
martimiz

11 March 2011 at 1:09am (Last edited: 11 March 2011 1:10am), Forum Moderator, 1095 Posts

You could add a special class to each submenu, based on its position in the main menu ($Pos) or its urlsegent ($URLSegment ). Something like:

<% if Menu(2) %>
   <ul class="menuType{$Pos}">
   <% control Menu(2) %>
      <li>
         <a href="$Link" class="$LinkingMode" title="Go to '$MenuTitle.XML'">$MenuTitle.XML</a>
      </li>
   <% end_control %>
   </ul>
<% end_if %>

Or, if you want it more dynamic, add a new database field to the page, update it from the backend and use that to name the class...

Avatar
s_a_m_y

11 March 2011 at 2:26am Community Member, 25 Posts

That looks exactly like what I need. $Pos gives me access to the single parent categories... I will try and report.
Thanks a lot!

Samy