Bread Crumb Navigation Example
You are here: Home > Examples : Bread Crumb Example Page
First, paste these two lines at the very top of your ASP page--above all other lines of code:
<% PageTitle = "Bread Crumb Example Page" %>
<!--#include file="includes/breadcrumb_navigation.asp" -->
<!--#include file="includes/breadcrumb_navigation.asp" -->
Then, replace your <title> tags with this code (You could also call the page title from a database). :
<title><% = PageTitle %></title>
Now, place this code where you want your bread crumb navigation to appear :
<% = TWDbreadcrumb_navigation(Request.ServerVariables("PATH_INFO")) %>
Finally, create an ASP page with ONLY this code in it; name it "breadcrumb_navigation.asp" and put it into your "includes" folder :
<%
Function TWDbreadcrumb_navigation(FullPath)
Do Until instr(1,FullPath,"/") = 0
' Create an array of letters in the alphabet.
Letters = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v",
"w","x","y","z")
' split on the /
tmpPath = mid(FullPath,1,instr(1,FullPath,"/")-1)
strTmpPath = Trim(tmpPath)
DirPath = DirPath & strTmpPath & "/"
' upshift the first character
firstLetter = ucase(mid(strTmpPath,1,1))
strTmpPath = firstLetter & mid(strTmpPath,2,len(strTmpPath))
' replace udnerscores with spaces and upshift the following character
for each letter in letters
strTmpPath = Replace(Trim(strTmpPath),"_" & lcase(letter)," " & UCase(letter))
next
' split the next one out
FullPath = mid(FullPath,instr(1,FullPath,"/")+1,Len(FullPath)-Len(tmpPath))
' separate them with >> symbols
IF strTmpPath = "" THEN
response.write "<a href=""/"" style=""text-decoration:none"">Home</a>"
ELSEIF strTmpPath = "Home" THEN
ELSE
response.write " > <a href=""" & DirPath & """ style=""text-decoration:none"">" & strTmpPath & "</a>"
END IF
Loop
IF PageTitle = "" THEN
response.write "<strong>" & " : Current Page " & "</strong>"
ELSE
response.write "<strong style=""color: #800000"">" & " : " & PageTitle & "</strong>"
END IF
End Function
%>
Function TWDbreadcrumb_navigation(FullPath)
Do Until instr(1,FullPath,"/") = 0
' Create an array of letters in the alphabet.
Letters = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v",
"w","x","y","z")
' split on the /
tmpPath = mid(FullPath,1,instr(1,FullPath,"/")-1)
strTmpPath = Trim(tmpPath)
DirPath = DirPath & strTmpPath & "/"
' upshift the first character
firstLetter = ucase(mid(strTmpPath,1,1))
strTmpPath = firstLetter & mid(strTmpPath,2,len(strTmpPath))
' replace udnerscores with spaces and upshift the following character
for each letter in letters
strTmpPath = Replace(Trim(strTmpPath),"_" & lcase(letter)," " & UCase(letter))
next
' split the next one out
FullPath = mid(FullPath,instr(1,FullPath,"/")+1,Len(FullPath)-Len(tmpPath))
' separate them with >> symbols
IF strTmpPath = "" THEN
response.write "<a href=""/"" style=""text-decoration:none"">Home</a>"
ELSEIF strTmpPath = "Home" THEN
ELSE
response.write " > <a href=""" & DirPath & """ style=""text-decoration:none"">" & strTmpPath & "</a>"
END IF
Loop
IF PageTitle = "" THEN
response.write "<strong>" & " : Current Page " & "</strong>"
ELSE
response.write "<strong style=""color: #800000"">" & " : " & PageTitle & "</strong>"
END IF
End Function
%>