3214 Posts in 848 Topics by 810 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 460 Views |
-
Customizing Menu

5 June 2012 at 7:55am
Hi all,
I'm not firm with Silverstripe and I want to place a sub in a sidebar with the following properties:
First If the submenu will NOT be displayed when the parent page has the ID = 11.
Second I wish that I just at this submenu the first of several <li> tags deposited in the CLASS attribute "firstItem".
So I could in fact represent the sub-menu with dashes between the menu items:MP1 | MP2 | MP3 | MP4 etc. ..
Can you give me one probably a tip?
best regards
Peter -
Re: Customizing Menu

6 June 2012 at 12:49pm Last edited: 6 June 2012 12:50pm
<% if Menu(2) %>
<% if ID != 11 %>
<ul class="subNavigation">
<% control Menu(2) %>
<li class="liSubNavigation $LinkingMode $FirstLast">
<a href="$Link" title="Go to the $Title.XML page" class="aSubNavigation $LinkingMode $FirstLast">$MenuTitle.XML</a> <% if Last %><% else %> | <% end if %>
</li>
<% end_control %>
</ul>
<% end_if %>
<% end_if %>There are a few parts to explain.
We check if the current page id is not equal to 11:
<% if ID != 11 %>
...
<% end_if %>We add the property $FirstLast to the class of the <li>/<a> which returns first or last if either of these cases are true. Note, this will make the class first, not firstItem as requested.
http://doc.silverstripe.org/sapphire/en/reference/built-in-page-controls#and-lt-if-first-and-gt-and-lt-if-last-and-gt-and-lt-if-middle-and-gt-firstlastWe add the dash by doing an if else on the last item like so:
<% if Last %><% else %> | <% end if %>
Hope this gives you what you want or at least the tools to start playing around to do what you want.
| 460 Views | ||
|
Page:
1
|
Go to Top |


