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

Auto Expanding menu and submenu


Reply

3 Posts   1199 Views

Avatar
TerryMiddleton

21 April 2009 at 11:13am Community Member, 108 Posts

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

Avatar
Carbon Crayon

21 April 2009 at 9:19pm (Last edited: 21 April 2009 9:20pm), Community Member, 598 Posts

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

Avatar
TerryMiddleton

22 April 2009 at 1:35am Community Member, 108 Posts

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