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

menu control

Go to End

3 Posts   1083 Views


Community Member, 31 Posts

10 March 2011 at 11:27pm

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?



Forum Moderator, 1391 Posts

11 March 2011 at 1:09am

Edited: 11/03/2011 1:10am

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) %>
			<a href="$Link" class="$LinkingMode" title="Go to '$MenuTitle.XML'">$MenuTitle.XML</a>
	<% end_control %>
<% 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...


Community Member, 31 Posts

11 March 2011 at 2:26am

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