Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

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

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

LinkingMode help needed......


Go to End


10 Posts   5580 Views

Avatar
Adamski

Community Member, 14 Posts

14 October 2008 at 2:10am

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>

Avatar
Willr

Forum Moderator, 5523 Posts

14 October 2008 at 10:03am

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

Avatar
Adamski

Community Member, 14 Posts

14 October 2008 at 10:10am

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

Avatar
bummzack

Community Member, 904 Posts

14 October 2008 at 10:42am

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

Avatar
Adamski

Community Member, 14 Posts

14 October 2008 at 10:48am

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>

Avatar
Adamski

Community Member, 14 Posts

14 October 2008 at 10:02pm

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

Avatar
Adamski

Community Member, 14 Posts

16 October 2008 at 12:43am

anyone?

Avatar
Adamski

Community Member, 14 Posts

16 October 2008 at 3:03am

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>

Go to Top