Jump to:

22972 Posts in 11596 Topics by 2824 members

General Questions

SilverStripe Forums » General Questions » menu control

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

Page: 1
Go to End
Author Topic: 691 Views
  • s_a_m_y
    Avatar
    Community Member
    22 Posts

    menu control Link to this post

    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

  • martimiz
    Avatar
    Forum Moderator
    1035 Posts

    Re: menu control Link to this post

    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...

  • s_a_m_y
    Avatar
    Community Member
    22 Posts

    Re: menu control Link to this post

    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

    691 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.