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, Ed, biapar, Willr, Ingo, swaiba

Auto Expanding menu and submenu

Go to End

3 Posts   1487 Views


Community Member, 108 Posts

21 April 2009 at 11:13am

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?


Carbon Crayon

Community Member, 598 Posts

21 April 2009 at 9:19pm

Edited: 21/04/2009 9:20pm

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


Community Member, 108 Posts

22 April 2009 at 1:35am


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>
<% end_control %>
<% end_if %>

Thanks again,