• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Small ASP question

Zucarita9000

Golden Member
Ok, so I have this navigation bar wich should show the links from a given section only when the user is browsing that specific portion of the site. Example:

The nav bar shows items like this:

Section 1
Link 1.1
Link 1.2
Link 1.3

Section 2
Link 2.1
Link 2.2
...
Etc.

So, when the user is browsing section 1, the navbar should only display the links from that section, hiding all the items from section 2:

User location: www.site.com/section1/
Nav bar:

Section 1
Link 1.1
Link 1.2
Link 1.3

Section 2
Section 3
...
Section 5

I've come up with this idea: Check the URL and display the correct items, like this:

<% If Request.ServerVariables("URL") ="/section1/" Then %>
Link 1.1
Link 1.2
Link 1.3
<% End If %>

This should show the correct itwems whenever the user is browsing the "section1" directory. However, it's not working at all.

Any ideas?
 
Originally posted by: Zucarita9000
Originally posted by: AFB
Print out the URL and see what it *is* equal to.

Not sure I follow... isn't that what I'm doing?

<% If Request.ServerVariables("URL") ="/section1/" Then %>


You're comparing it and I guess it's not working.

Print out the value of URL so you can see why it's not cimplaring correctly.
 
you are printing the links no matter what the result of the conditional is....

<% If Request.ServerVariables("URL") ="/section1/" Then %>
Link 1.1
Link 1.2
Link 1.3
<% End If %>


needs to be like this...

<% If Request.ServerVariables("URL") ="/section1/" Then
response.write("Link 1.1 ")
response.write("Link 1.2 ")
response.write("Link 1.3 ")
End If %>

EDIT:

You may also want to consider using InStr() as I am not sure what the URL variable contains. It might be the full URL not just the end section. It may be fouling up your conditional results.

<% if InStr(request.servervariables("URL"),"section1") then

that sort of thing.

 
Couple possibilities:

1. URL might have a page name after the /. You can try instr or you can do a left of the URL.

2. Might have case sensitivity issues. Do an LCASE of the URL before comparing.
 
Originally posted by: brentman
you are printing the links no matter what the result of the conditional is....

<% If Request.ServerVariables("URL") ="/section1/" Then %>
Link 1.1
Link 1.2
Link 1.3
<% End If %>


needs to be like this...

<% If Request.ServerVariables("URL") ="/section1/" Then
response.write("Link 1.1 ")
response.write("Link 1.2 ")
response.write("Link 1.3 ")
End If %>


This is not necessary. I do the inline one frequently and it works just fine.
 
Back
Top