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

Menu help


5 Posts   1436 Views


15 January 2010 at 4:52am Community Member, 6 Posts

Hi, I'm having trouble displaying ym menu correctly in silverstripe. My menu is as followed;

-- HTML --

         <li class="first"><a href="#" title="Go to the Welcome"><span>Home</span></a></li>
         <li><a href="#" title="Go to the Website design" class="link"><span>Design</span></a></li>
         <li><a href="#" title="Go to the Content management systems" class="link"><span>Content Management Systems</span></a></li>
         <li><a href="#" title="Go to the eCommerce systems" class="link"><span>eCommerce</span></a></li>
         <li><a href="#" title="Go to the Search engine services" class="link"><span>Search</span></a></li>
         <li><a href="#" title="Go to the Pro Image Manager" class="link"><span>PIM</span></a></li>
         <li><a href="#" title="Go to the News" class="link"><span>News</span></a></li>
         <li><a href="#" title="Go to the Our clients" class="link"><span>Our clients</span></a></li>
         <li class="last"><a href="/contact-us/" title="Go to the Contact us" class="link"><span>Contact us</span></a></li>


-- CSS --

#nav {
   margin-top: 10px;
#nav ul {
   padding-left: 0px;
#nav ul li {
   border-right:1px solid #CCCCCC;
#nav ul li.first {
   margin-left: -10px;
#nav ul li.last {      
#nav ul li a {
   padding: 10px 10px 10px 10px;   
#nav li a:hover {   

-- SS --

<% control Menu(1) %>

<li class="first">
<a class="$LinkingMode" href="$Link" title="Go to $Title">$MenuTitle</a>

<% end_control %>

and that's the code I'm trying to use to display my menu, the problem is that i have a set class for the first list item to reduce the margin so first problem is how to set a class for the first list?

and secondly all my links are displaying /page.html or which ever the link is straignt after the link.

Any help would be great, thanks!


15 January 2010 at 12:22pm Forum Moderator, 5511 Posts

You can use the $First variable if you want to add a class to the first item. (Also a $Last if you need)

<% if First %>class="first"<% end_if %>


15 January 2010 at 7:34pm Community Member, 901 Posts

Yes, as Willr said, or use $FirstLast to get the appropriate class:

<li class="$FirstLast">

The above will have class="first" on the first item and class="last" on the last item.


20 January 2010 at 7:00pm Community Member, 12 Posts

Hey do you guys know of any tutorials for how to add Mega drop down menus (for navigation).....and have the content controlled through SS? Thank you...


20 January 2010 at 7:12pm Forum Moderator, 5511 Posts

Silver - Please do not cross post. If people can / want to answer you they can on the thread you created You shouldn't then add replies to threads unrelated to your issue.