Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » LinkingMode help needed......

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

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

Page: 1 2
Go to End
Author Topic: 4599 Views
  • Adamski
    Avatar
    Community Member
    14 Posts

    LinkingMode help needed...... Link to this post

    Hello everyone....!

    I have a vertical menu with indented children and the code below works well for me. The only thing I cannot get to work is the Linking Mode to work. I basically want the active page to be highlighted regardless of whether it is level 1, 2 or 3 of the nav.

    Can anyone help me out? I'll buy you a chocolate bar!

    Thanks
    /Adam

    <ul>
             <% control Menu(1) %>
                <li><a href="$Link" title="Go to the $Title.XML page" <% if LinkingMode %>class="$LinkingMode"><% end_if %>$MenuTitle</a>
                <% if LinkOrSection = section %>      
                <% if Children %>
                <div id="leftbox_sub">
                   <ul>
                   <% control Children %>
                   <li><a href="$Link" title="Go to the $Title.XML page">$MenuTitle</a>
                            <% if LinkOrSection = section %>      
                            <% if Children %>
                            <div id="leftbox_sub2">
                            <ul>
                            <% control Children %>
                            <li><a href="$Link" title="Go to the $Title.XML page">$MenuTitle</a>
                                        <% if LinkOrSection = section %>      
                                        <% if Children %>
                                        <div id="leftbox_sub3">
                                        <ul>
                                        <% control Children %>
                                        <li><a href="$Link" title="Go to the $Title.XML page">$MenuTitle</a></li>
                                        <% end_control %>
                                        </ul>
                                        </div>
                                        <% end_if %>
                                        <% end_if %>
             
                            </li>
                            <% end_control %>
                            </ul>
                            </div>
                            <% end_if %>
                            <% end_if %>
                   </li>
                   <% end_control %>
                   </ul>
                </div>
                <% end_if %>
                <% end_if %>
                </li>
             <% end_control %>
          </ul>

  • Willr
    Avatar
    Forum Moderator
    5464 Posts

    Re: LinkingMode help needed...... Link to this post

    ctive page to be highlighted regardless of whether it is level 1, 2 or 3 of the nav.

    Then you would use class="$LinkOrSection" which will return 'link' if its not on this page or a child. Or 'section' if its on this page or a child

  • Adamski
    Avatar
    Community Member
    14 Posts

    Re: LinkingMode help needed...... Link to this post

    and do I apply that class to the <ul> or <li>?

  • banal
    Avatar
    Community Member
    901 Posts

    Re: LinkingMode help needed...... Link to this post

    You should apply the class to the <li> or the <a> tag. Of course you'll still need a appropriate css stylesheet.

  • Adamski
    Avatar
    Community Member
    14 Posts

    Re: LinkingMode help needed...... Link to this post

    so my code should look like this..... (see below)

    and then I create classes for 'link' and 'section'?

    (sorry to be so slow!)

    >
    <% control Menu(1) %>
    <li><a href="$Link" title="Go to the $Title.XML page" class="$LinkOrSection">$MenuTitle</a>
    <% if LinkOrSection = section %>
    <% if Children %>
    <div id="leftbox_sub">
    <ul>
    <% control Children %>
    <li><a href="$Link" title="Go to the $Title.XML page" class="$LinkOrSection">$MenuTitle</a>
    <% if LinkOrSection = section %>
    <% if Children %>
    <div id="leftbox_sub2">
    <ul>
    <% control Children %>
    <li><a href="$Link" title="Go to the $Title.XML page" class="$LinkOrSection">$MenuTitle</a>
    <% if LinkOrSection = section %>
    <% if Children %>
    <div id="leftbox_sub3">
    <ul>
    <% control Children %>
    <li><a href="$Link" title="Go to the $Title.XML page" class="$LinkOrSection">$MenuTitle</a></li>
    <% end_control %>
    </ul>
    </div>
    <% end_if %>
    <% end_if %>

    </li>
    <% end_control %>
    </ul>
    </div>
    <% end_if %>
    <% end_if %>
    </li>
    <% end_control %>
    </ul>
    </div>
    <% end_if %>
    <% end_if %>
    </li>
    <% end_control %>
    </ul>

  • Adamski
    Avatar
    Community Member
    14 Posts

    Re: LinkingMode help needed...... Link to this post

    hmmm..... this didn't work. Where are I going wrong?

  • Adamski
    Avatar
    Community Member
    14 Posts

    Re: LinkingMode help needed...... Link to this post

    anyone?

  • Adamski
    Avatar
    Community Member
    14 Posts

    Re: LinkingMode help needed...... Link to this post

    I've attached a screenshot of the effect I want to achieve.

    Level 1 - Black
    Level 2 - Blue
    Level 3 - Red
    Level 4 - Green

    In this screenshot the page 'Bronze Award' is the active page and therefore the link I want to show in it's active state.

    Hope someone out there can help me....! Here is my code as it stands

    <ul>
          <% control Menu(1) %>
          <li><a href="$Link" title="Go to the $Title.XML page" class="$LinkOrSection">$MenuTitle</a>
          <% if LinkOrSection = section %>
          <% if Children %>
          <div id="leftbox_sub">
          <ul>
          <% control Children %>
          <li><a href="$Link" title="Go to the $Title.XML page" class="$LinkOrSection">$MenuTitle</a>
          <% if LinkOrSection = section %>
          <% if Children %>
          <div id="leftbox_sub2">
          <ul>
          <% control Children %>
          <li><a href="$Link" title="Go to the $Title.XML page" class="$LinkOrSection">$MenuTitle</a>
          <% if LinkOrSection = section %>
          <% if Children %>
          <div id="leftbox_sub3">
          <ul>
          <% control Children %>
          <li><a href="$Link" title="Go to the $Title.XML page" class="$LinkOrSection">$MenuTitle</a>
          </li>
          <% end_control %>
          </ul>
          </div>
          <% end_if %>
          <% end_if %>
          </li>
          <% end_control %>
          </ul>
          </div>
          <% end_if %>
          <% end_if %>
          </li>
          <% end_control %>
          </ul>
          </div>
          <% end_if %>
          <% end_if %>
          </li>
          <% end_control %>
    </ul>

    4599 Views
Page: 1 2
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.