Jump to:

23451 Posts in 18899 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » Auto Expanding menu and submenu

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: 1190 Views
  • TerryMiddleton
    Avatar
    Community Member
    108 Posts

    Auto Expanding menu and submenu Link to this post

    When someone is at the home page, I need to have one of the menu items and its submenu items expanded out.

    Has anyone ever done this?

    Terry

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Auto Expanding menu and submenu Link to this post

    I think this can be done using CSS classes in the same way as $LinkingMode works, provided that is how your menu knows what to expand.

    So you could have a condition like this:

    <% if URLSegment = home %>
    <a class="Open" href="$Link">$MenuTitle</a>
    <% else %>
    <a href="$Link">$MenuTitle</a>
    <% end_if %>

    or you could create a function IsOpen() that returned the relevant class (if any) and call it via class="$IsOpen".

  • TerryMiddleton
    Avatar
    Community Member
    108 Posts

    Re: Auto Expanding menu and submenu Link to this post

    Aram,

    You rock - thank you for this. Worked perfectly. Here's how I implemented it - works like a charm.

    <% if URLSegment = rit-113-imrt-qa-software %>
    <% control Children %>
    <ul id="smenu">
    <li class="sm$ID"><a href="$Link" title="Go to the $Title.XML page" class="sa$ID">$MenuTitle</a></li>       
    </ul>
    <% end_control %>
    <% end_if %>

    Thanks again,

    Terry

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