Jump to:

22976 Posts in 11667 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » Show Top Level Page on any SubPage (SOLVED)

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: 1449 Views
  • Hello_electro
    Avatar
    Community Member
    80 Posts

    Show Top Level Page on any SubPage (SOLVED) Link to this post

    Hi Everyone:

    I have a level 2 navigation that shows up whenever you go past the main navigation links. The navigation box will show:

    Main Page Title (with url)
    sub page
    sub page
    sub page
    etc

    I am fine when i am 1 level deep. For example i click on About (from main nav) and choose Board Members from the drop down.

    The Nav box will then show:

    About
    sub page
    sub page
    Board mmbers
    etc

    The problem arises when i click on Board Members. The Nav box then shows:

    Board Members
    sub page
    sub page
    Board Members
    etc

    What I want to show is:

    About
    sub page
    sub page
    Board Members
    etc

    This way, no matter how far you drill down the top header of the Nav box will always show the main link with its level 2 links below.

    Here is the code I am using:

    <% if Menu(2) %>
       <div id="RightNavLatestInfoContainer">
          <div id="RightNavLatestInfoTop"></div>
          <div id="RightNavLatestInfoBody">
             <div id="subnavbox">
             <% if Level(2) %>       
       <div class="subnavheader"><a href="$Parent.Link">$Parent.Title</a></div>
             <% else %>
       <div class="subnavheader"><a href="$Link">$Title</a></div>
             <% end_if %>
       <div class="RecentInfoBlocksRight">
             <ul>
                <% control Menu(2) %>
                <li class="$LinkingMode"><span class="bulletback"><a href="$Link">$MenuTitle</a></span></li>
                <% end_control %>
             </ul>
       </div>
       </div>
       </div>
    <div id="RightNavLatestInfoBottom"></div><!--This is and ends the bottom image for Latest Info -->
    </div><!--This ends the container for the latest info it is fluid vertically-->
    <% end_if %>

    I am pretty sure it has to do with my if statements and controls. I have spent 4 hours with no luck, so am turning to you guys. All I want to make sure is that the "subnavheader" div always shows the top level navigation and the "RecentInfoBlocksRight" shows the level 2 navigation no matter if I go to level 3, 4, 5 etc.

    HELP!!!

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Show Top Level Page on any SubPage (SOLVED) Link to this post

    Instead of $Parent.Title which will take the parent - so always 1 level up, try $Level(2).Title or $Level(1).Title which will always return the 2nd level and 1st level title respectively.

  • Hello_electro
    Avatar
    Community Member
    80 Posts

    Re: Show Top Level Page on any SubPage (SOLVED) Link to this post

    Will

    Thanks so much. Oddly, I tried that before, but looks like I had other code messing it up and thought maybe that option no longer worked. Thanks for clarifying, i can actually sleep tonight!!!

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