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.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

CSS Sprites and Silverstripe

Go to End

4 Posts   1846 Views


Forum Moderator, 4102 Posts

18 September 2007 at 9:12am

Edited: 18/09/2007 9:13am

Using the Menu control, how can I add a unique ID to every LI tag that gets printed? If I use the $Title or $MenuTitle variables, I end up with spaces in the name, and if I use $Link, I end up with slashes in the name, all of which are invalid. Any ideas? Is there a variable available that outputs the current iteration of the loop? Or maybe the URL text of the page without the slashes? How is this usually done?



Community Member, 231 Posts

18 September 2007 at 9:35am

You can use $URLSegment


Community Member, 86 Posts

18 September 2007 at 7:16pm

Depending on what I'm doing, I'll use $URLSegment, $ID or $Pos... I can't remember if $Pos was something I hacked in or not, it's quite possible that it is (it returns the nth item in the list, e.g. 3 for the third item etc).

$ID returns the database ID of the current page/data object. Obviously, you can't use these on their own, I normally prefix them with a descriptor - e.g. <li id="Booking_$ID"> or similar.


Forum Moderator, 4102 Posts

19 September 2007 at 1:21am

Wow.. this is great. Thanks, guys. How do you know all those template variables? If I had a list of all of those, I could have figured it out, but I looked everywhere. Any leads?