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

Custom external links within navigation control


Go to End
Reply


6 Posts   1873 Views

Avatar
Andrew Houle

Community Member, 134 Posts

6 November 2008 at 6:48am

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

Community Member, 712 Posts

6 November 2008 at 9:52am

Edited: 06/11/2008 9:52am

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

Community Member, 134 Posts

6 November 2008 at 10:53am

Perfect! That works great, thanks for your help!

Avatar
Andrew Houle

Community Member, 134 Posts

6 November 2008 at 10:59am

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

Community Member, 712 Posts

6 November 2008 at 12:04pm

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

Avatar
Andrew Houle

Community Member, 134 Posts

7 November 2008 at 4:05am

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!