navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

ASP Variables passed to include

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> ASP Variables passed to include
Page: [1]
 
BobbyDouglas

 

Posts: 5432
Joined: 5/15/2003
From: Arizona
Status: offline

 
ASP Variables passed to include - 2/6/2008 2:34:56   
I have an ASP page with the following include:

<!-- #include virtual="/_includes/main_nav.inc.asp" -->


main_nav.inc.asp contains:

<ul>
    <li><a href="/About-Us/">About Us</a></li>
    <li><a href="/Contact-Us/">ContactUs</a></li>
</ul>


When I use the include on the About Us page, the code displayed should be:

<ul>
    <li class="on"><a href="/About-Us/">About Us</a></li>
    <li><a href="/Contact-Us/">ContactUs</a></li>
</ul>


What's the best way to do this?

Using PHP, I can accomplish this using:

<?php $on="About Us"; include("/_includes/main_nav.inc.php"); ?>


Where main_nav.inc.php looks like:

<ul>
    <li<? if($page_on=="About Us"){ echo class="on"; }?>><a href="/About-Us/">About Us</a></li>
    <li><a href="/Contact-Us/">ContactUs</a></li>
</ul>


Basically, the About Us page will only have the class="on" when the include file contains a variable named $page_on that is equal to "About Us"

Also, if it makes a difference, maybe I ASP has a way to grab the folder name, and check if folder name == "About-Us"

_____________________________

Arizona Web Design - Mr Bobs Web Design in Arizona
The Arizona Web Hosting Challenge
rdouglass

 

Posts: 9167
From: Biddeford, ME USA
Status: offline

 
RE: ASP Variables passed to include - 2/6/2008 8:36:18   
quote:

<li<? if($page_on=="About Us"){ echo class="on"; }?>><a href="/About-Us/">About Us</a></li>


One way in ASP is to do something like this:

<li<%IF Instr(Request.Servervariables("URL"),"About-Us") > 0 Then%> class="on"<%End If%>><a href="/About-Us/">About Us</a></li>

Instr looks for the string "About-Us" in the URL returned by Request.servervariables("URL")

That help any?

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to BobbyDouglas)
BobbyDouglas

 

Posts: 5432
Joined: 5/15/2003
From: Arizona
Status: offline

 
RE: ASP Variables passed to include - 2/6/2008 11:22:08   
Roger,

When I try that, I believe the value of
Request.Servervariables("URL")
is actually the location of the include file, and not the end file, such as the About Us.

_____________________________

Arizona Web Design - Mr Bobs Web Design in Arizona
The Arizona Web Hosting Challenge

(in reply to rdouglass)
rdouglass

 

Posts: 9167
From: Biddeford, ME USA
Status: offline

 
RE: ASP Variables passed to include - 2/6/2008 12:55:02   
Have you tried it? It doesn't for me. It returns what's in the address bar minus the domain and any querystring data) for me anyways.

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to BobbyDouglas)
Spooky

 

Posts: 26597
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: ASP Variables passed to include - 2/6/2008 13:37:10   
The way Roger did it is what Ive used in the past.

Another way is to use server.execute if you have different asp nav pages (although it is longer :-)
If pagename="nav" then
Server.Execute("/_includes/main_nav.inc.asp") 
elseif If pagename="home" then
Server.Execute("/_includes/main_hm.inc.asp") 
End if


Just to expand on what Roger did, set your page name as a variable first :

<%
pagename = lcase(Request.Servervariables("URL"))
%>

<!-- #include virtual="/_includes/main_nav.inc.asp" -->

<li<%IF lcase(Instr(pagename,"about-us")) > 0 Then%> class="on"<%End If%>><a href="/About-Us/">About Us</a></li> 


< Message edited by Spooky -- 2/6/2008 13:48:25 >

(in reply to rdouglass)
BobbyDouglas

 

Posts: 5432
Joined: 5/15/2003
From: Arizona
Status: offline

 
RE: ASP Variables passed to include - 2/6/2008 15:00:53   
Don't know why but it is working now, must have overlooked something before.

Thanks guys!

This is a powerful way to handle navigation for pages :)

_____________________________

Arizona Web Design - Mr Bobs Web Design in Arizona
The Arizona Web Hosting Challenge

(in reply to Spooky)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> ASP Variables passed to include
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts