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.

Archive

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

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

Custom external links within navigation control


Reply

6 Posts   1635 Views

Avatar
Andrew Houle

6 November 2008 at 6:48am Community Member, 132 Posts

I want to link to external pages within my navigation. Is it possible to check the urlsegment within the control loop? Something like this:

<ul class="ir nav">
   <% control Menu(1) %>   
      <li class="ir-$URLSegment"><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode"><em>$MenuTitle</em></a>
         
         <ul id="sub-$URLSegment">
            <% control Children %>
               <li><a href="$Link">$MenuTitle</a></li>
               
            <% end_control %>
            <% if $URLSegment="admissions" %>
            <li><a href="#">Test Link</a></li>
            <% end-if %>
         </ul>
      
      </li>
   <% end_control %>
</ul>

Basically I want to use the $URLSegment variable to test if I'm on the admissions page, and if so print links accordingly.

Thanks for the help.

Avatar
Hamish

6 November 2008 at 9:52am (Last edited: 6 November 2008 9:52am), Community Member, 712 Posts

yes, but withing <% %> tags, you drop the dollar sign and the quotes. Also use == instead of =.

ie:

<% if URLSegment == admissions %>
<li><a href="#">Test Link</a></li>
<% end_if %>

Avatar
Andrew Houle

6 November 2008 at 10:53am Community Member, 132 Posts

Perfect! That works great, thanks for your help!

Avatar
Andrew Houle

6 November 2008 at 10:59am Community Member, 132 Posts

I just realized my logic is screwy. I need the navigation to add links to external pages. For instance, the prior logic only added the "Test Link" where URLSegment == admissions. I need it to add that test link all the time under the admissions navigation. Is that possible? I'll keep looking.

Avatar
Hamish

6 November 2008 at 12:04pm Community Member, 712 Posts

Move it into the control loop. At the moment you have it outside of the control loop.

Avatar
Andrew Houle

7 November 2008 at 4:05am Community Member, 132 Posts

Unfortunately even though that logic seems better, the "Test Link" doesn't appear in the menu. Here is what my code looks like now:

<ul class="ir nav">
   <% control Menu(1) %>   
      <li class="ir-$URLSegment"><a href="$Link" title="Go to the $Title.XML page" class="$LinkingMode"><em>$MenuTitle</em></a>
         
         <ul id="sub-$URLSegment">
            <% control Children %>
               <li><a href="$Link">$MenuTitle</a></li>
               <% if URLSegment == admissions %>
                  <li><a href="#">Test Link</a></li>
               <% end_if %>
            <% end_control %>
            
         </ul>
      
      </li>
   <% end_control %>
</ul>

Sorry to keep this going, I was just hoping this sort of thing would be rather simple.

Thanks again for your help!