Jump to:

3445 Posts in 1031 Topics by 872 members

Template Questions

SilverStripe Forums » Template Questions » How to build a navigation with different colors

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

Page: 1
Go to End
Author Topic: 695 Views
  • TomMiller
    Avatar
    Community Member
    26 Posts

    How to build a navigation with different colors Link to this post

    Hi all,
    i am trying to build a navigation which is supposed to have a different color from a certain point on. I'd like to use ul and ol in my css. SS's output from the menu control should look like this:

    <div id="subnav">
    <ul>
    <li><a class="current" href="content1.htm" title="title1">Title1</a></li>
    <li><a href="content2.htm" title="title2">Title2</a></li>
    <li><a href="content3.htm" title="title3">Title3</a></li>
    <li><a href="content4.htm" title="title4">Title4</a></li>
    </ul>
    <ol>
    <li><a href="content5.htm" title="title5">Title5</a></li>
    <li><a href="content6.htm" title="title6">Title6</a></li>
    <li><a href="content7.htm" title="title7">Title7</a></li>
    </ol>
    </div>

    All pages content1 - content7 must be on the same level in the sitetree.
    Can anybody please lead me to the smartest way to do this?

    Thanks,
    Tom

  • x75
    Avatar
    Community Member
    42 Posts

    Re: How to build a navigation with different colors Link to this post

    Hi,

    if you allways want to do that after the 4th element and you know there are at least 5 elements you could simply use $Pos:

    <div id="subnav">
    <ul>
    <% control Menu(1) %>
    <% if Pos = 5 %>
    </ul><ol>
    <% end_if %>
    <li><a class="$LinkOrCurrent" href="$Link" title="$Title.XML">$MenuTitle</a></li>
    <% end_control %>
    </ol>
    </div>

  • TomMiller
    Avatar
    Community Member
    26 Posts

    Re: How to build a navigation with different colors Link to this post

    Thanks for your help! Unfortunately this is not an option because of flexibilty requirements. Can i just use another class for the pagetype and a syntax like <% if class=foo %> somehow?

  • Ryan M.
    Avatar
    Community Member
    309 Posts

    Re: How to build a navigation with different colors Link to this post

    Yes, you can do that with page class names.

    <% if ClassName = YourClassName %>
    do something
    <% end_if %>

  • TomMiller
    Avatar
    Community Member
    26 Posts

    Re: How to build a navigation with different colors Link to this post

    Thanks again! I combined both answers and it works perfect.

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