17691 Posts in 4607 Topics by 2180 members
General Questions
SilverStripe Forums » General Questions » Add a class to the last <li> in my navigation
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba
|
Page:
1
|
Go to End | |
| Author | Topic: | 1031 Views |
-
Add a class to the last <li> in my navigation

13 August 2009 at 4:07am Last edited: 13 August 2009 4:08am
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?
-
Re: Add a class to the last <li> in my navigation

13 August 2009 at 4:21am
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
-
Re: Add a class to the last <li> in my navigation

13 August 2009 at 9:21am
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.
-
Re: Add a class to the last <li> in my navigation

13 August 2009 at 11:17pm Last edited: 13 August 2009 11:19pm
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 -
Re: Add a class to the last <li> in my navigation

13 August 2009 at 11:26pm
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>
Then target in CSS with something likeul li .Last{
background-image: none;
}Hope that helps
-
Re: Add a class to the last <li> in my navigation

15 August 2009 at 4:11am
Yea that is exactly what I needed, thanks.
I tried this orginally but it did not work, turns out it was cached
| 1031 Views | ||
|
Page:
1
|
Go to Top |

