Directory Drill Down   
 

Many websites have some form of hyperlink navigation as you drill down further into the site.  Many times the scheme that the drilldown follows is the directory path of the site.  If this is how our site is structured you may benefit from this example that can be placed on any asp document.  Utilizing two server variables (http_host and script_name) and splitting the script_name by the "/" delimiter you can effortlessly add hyperlinks to all the parent directories in your web.


<title>Directory Drill Down</title>
<body bgcolor="#FFFFFF">
<%
'Capture the name of the host server and add http:// to the varible
host= "http://" & request.servervariables("http_host")

'Caputre the name of the page as well as directory structure
script_name=request.servervariables("script_name")

'Split the directory tree into an arry by /
split_name=split(script_name,"/")

'Sets the number of directory levels down
'this document is from the top level directory
'--remove the -1 if you wish to display the name of the page
' with the hyperlink drill down --
num_directory=ubound(split_name)-1
%>

<a href="<%= host %>">
<%= host %></a><%
'Loop that will output all of the parent directories
'and hyperlink them

for counter= 1 to (num_directory)
link=link & "/"& split_name(counter) %>/<a
href="<%= link %>"><%= split_name(counter) %></a><%
next %>


My3C's
perrychicker
It's easy... it's a PSACAKE!
Back | Tell A Friend | Search this Site
1998 - 2014 psacake.com
Version 3.23

Send me One Million FREE Guaranteed Visitors