Breadcrumb script for ASP site using SSI

Posted on 2010-04-05
Medium Priority
Last Modified: 2012-05-09
I have an intranet site that has about 50 pages of info, links, forms and other misc stuff that I would like to add bread crumbs. For simplicity sake I put the asp pages in the main directory with the include files and the scripts I have found so far just read the path to the file, which of course doesn't work for me.

For example, on the "Request for Leave" form page that has 2 includes (header and footer) and is linked on the "Forms" page (with all the other forms) the bread crumb scripts I have found so far all show "Home > Request for Leave" but I want it to read "Home > Forms > Request for Leave"

I really don't want to hand code all the breadcrumbs but I can't seem to find or write a script that works. How do it?
Question by:Bob Stone
  • 2

Accepted Solution

Bob Stone earned 0 total points
ID: 29902232
I figured it out.
Function BreadCrumb(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))

	'## 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 Page</a>"
	ELSEIF strTmpPath = "Home" THEN
		response.write " &gt; <a href=""" & DirPath & """ style=""text-decoration:none"">" & strTmpPath & "</a>"

IF PageTitle = "" THEN
	response.write " &#187; Current Page"
	response.write " &#187; " & PageTitle

End Function %>


In <head> of header file
<!--#include virtual ="/scripts/breadcrumb.asp"-->


On each page where breadcrumbs should go
<% PageTitle = "<a href=""prior page.asp"" style=""text-decoration:none"">Contacts</a> &#187; Places" %>

<% = BreadCrumb(Request.ServerVariables("PATH_INFO")) %>

Which gives me "Home  » Contacts » Places"

Open in new window


Author Comment

by:Bob Stone
ID: 29902654
Though I am still not clear exactly how much time that will save from just doing it manually, but I guess the format will be consistent all the way through and if I decide to change the format or something, it will help somewhat.

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Ready to get certified? Check out some courses that help you prepare for third-party exams.
This article is about the challenges faced by Android app developers.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question