Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » CSS Sprites and Silverstripe

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

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

Page: 1
Go to End
Author Topic: 1314 Views
  • UncleCheese
    Avatar
    4085 Posts

    CSS Sprites and Silverstripe Link to this post

    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?

    Thanks.

  • Andy
    Avatar
    230 Posts

    Re: CSS Sprites and Silverstripe Link to this post

    You can use $URLSegment

  • Matt
    Avatar
    Core Development Team
    84 Posts

    Re: CSS Sprites and Silverstripe Link to this post

    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.

  • UncleCheese
    Avatar
    4085 Posts

    Re: CSS Sprites and Silverstripe Link to this post

    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?

    1314 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.