Directory Drill Down

http://psacake.com/web

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.
<%
 '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 %>


hyperlink navigation asp navigation bar directory structure path through site


Back To Top
© 1998 - 2024 psacake.com
Version 7.21 | Advertise on this site