ASP Crumb Trail
I use a nested directory structure for this site and wanted to automatically build a "crumb trail" for each page using ASP.
Each directory in the site has a "default.asp" so building links for a trail back to the home page is easy.
The Code
<style>
.History2
{
COLOR: #000000;
FONT-SIZE: 10px;
FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif;
TEXT-DECORATION: None;
FONT-WEIGHT: Bold;
}
a.History
{
COLOR: #000000;
FONT-SIZE: 10px;
FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif;
TEXT-DECORATION: Underline;
FONT-WEIGHT: Bold;
}
a.History:link
{
COLOR: #000000;
FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif;
TEXT-DECORATION: Underline;
FONT-WEIGHT: Bold;
}
a.History:visited
{
COLOR: #000000;
FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif;
TEXT-DECORATION: Underline;
FONT-WEIGHT: Bold;
}
a.History:hover
{
COLOR: #000000;
FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif;
TEXT-DECORATION: None;
FONT-WEIGHT: Bold;
}
</style>
<span class="History2">You are in: </span>
<a href="/default.asp" class="History">home</a>
<span class="History2"> > </span>
<%
'get the name of the page
my_URL = Request.ServerVariables("SCRIPT_NAME")
'find the first "/" and store its position
old_URL_Start = InStr(my_URL,"/")
'start a counter
count = 0
'start loop
do
'find the next "/"
URL_Start = InStr(old_URL_Start+1, my_URL,"/")
'exit loop if there are no more "/"s to be found
if count > 10 OR NOT URL_Start > 0 then
exit do
end if
'extract the directory name and append to URL
myDir = myDir & "/" & mid(my_URL, old_URL_Start+1, URL_Start-old_URL_Start-1)
'extract the directory name
myDirName = mid(my_URL, old_URL_Start + 1, URL_Start - old_URL_Start - 1)
'write link to client
Response.Write "<a href=""" & myDir & """ class=""History"">"
Response.Write Replace(myDirName, "_"," ")
Response.Write "</a><span class=""History2""> > </span>"
'store the position of this "/" for the next search
old_URL_Start = URL_Start
'increase counter (stops infinite loops if something goes wrong)
count = count + 1
'loop back
loop while InStr(old_URL_Start+1, my_URL,"/")
%>
|