I have navigation which has a pipe.... a background image positioned right on the <li>
Is there some code I can add that will add a class to the last <li> in my navigation so I can remove the background image on the last one?
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
I have navigation which has a pipe.... a background image positioned right on the <li>
Is there some code I can add that will add a class to the last <li> in my navigation so I can remove the background image on the last one?
You could use the <% if Last %> ... <% end_if %> structure in your template. This link might be helpful: http://doc.silverstripe.com/doku.php?id=built-in-page-controls
You can just include $FirstLast as a class inside your normal control and it will add in 'First' and 'Last' to the respective items in the menu.
Thanks for the replies.
howardgrigg how can use $FirstLast then. This is my menu:
<ul>
<% control Menu(1) %>
<li><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode"><span>$MenuTitle</span></a></li>
<% end_control %>
</ul>
Thanks
Ashley
You can just go:
<ul>
<% control Menu(1) %>
<li class="$FirstLast"><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode"><span>$MenuTitle</span></a></li>
<% end_control %>
</ul>
ul li .Last{
background-image: none;
}
Hope that helps :)
Yea that is exactly what I needed, thanks.
I tried this orginally but it did not work, turns out it was cached :-)