Jump to:

23380 Posts in 18311 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » Menu with alternating colours

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 1061 Views
  • mschiefmaker
    Avatar
    Community Member
    187 Posts

    Menu with alternating colours Link to this post

    I have a menu which creates its top level using code

        <% control Menu(1) %>   
           <% if Children %>
             <li ><a href="#" onFocus="if(this.blur)this.blur()" class="$LinkingMode" >$MenuTitle.XML ...

    I want to change this so that it every second menu option is a different colour i.e. odd it is organge, even it is grey.

    To this I want to test against its order in the sitetree (unless someone thinks there is a better way) but I am not sure what this variable is called?

    Thanks

    Catherine

  • Nobrainer Web
    Avatar
    Community Member
    134 Posts

    Re: Menu with alternating colours Link to this post

    The below should work (see http://doc.silverstripe.org/doku.php?id=built-in-page-controls)

    <% control Menu(1) %>
    <% if Children %>
    <li class="$EvenOdd"><a href="#" onFocus="if(this.blur)this.blur()" class="$LinkingMode" >$MenuTitle.XML ...

    $EvenOdd will return even or odd, so just make two css classes with these names and style as you wish.
    --

    Thomas B. Nielsen
    http://www.lund-co.dk

  • mschiefmaker
    Avatar
    Community Member
    187 Posts

    Re: Menu with alternating colours Link to this post

    Hi Thomas

    Thank you, worked a treat!

    Catherine

    1061 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.