Solved

Bread crumb path on homepage

Posted on 2003-11-26
10
528 Views
Last Modified: 2008-02-01
There is a bread crumb path on my company's intranet homepage.   I'm using ASP & HTML to build this homepage.  

eg.  You are here:  Home / HR / Announcements / Benefits / current page

How do I make each section a clickable link to it's respective folder?  The path should show what page the user is on in relation to the homepage and the links followed to get there.

eg.  Clicking on Home takes you to homepage
       Clicking on HR takes you to the HR folder
       Clicking on Announcements takes you to the Announcements folder
       ....etc

Please provide ASP code.

0
Comment
Question by:jckwoo
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 4

Accepted Solution

by:
Iguanasan earned 125 total points
ID: 9824833
<%
DIM sTemp, aTemp, sBreadCrumbs, sNewPath
sTemp = Request.ServerVariables("PATH_INFO")
aTemp = Split(sTemp,"/")
for i = 0 to UBound(aTemp)
      sNewPath = sNewPath & aTemp(i) & "/"
      sBreadCrumbs = sBreadCrumbs & "<a href=" & sNewPath & ">"
      if Len(aTemp(i)) = 0 then
            sBreadCrumbs = sBreadCrumbs & "Home"
      else
            sBreadCrumbs = sBreadCrumbs & aTemp(i)
      end if
      sBreadCrumbs = sBreadCrumbs & "</a> | "
next
sBreadCrumbs = Left(sBreadCrumbs,Len(sBreadCrumbs)-3) ' Drop last separator
Response.Write sBreadCrumbs
%>
0
 

Author Comment

by:jckwoo
ID: 9825051
Hi there,
It's displaying the name of the asp file where I saved your code.

eg.  Home | test.asp
0
 
LVL 4

Expert Comment

by:Iguanasan
ID: 9825197
If you don't want that then change

for i = 0 to UBound(aTemp)

to

for i = 0 to UBound(aTemp) - 1
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 9825750
What about using this Javascript breadcrumbs

<html>
<head>
<title></title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
<!--

function breadCrumbs(delimiterStr) {
loc2 = window.location.toString();
loc = loc2.toLowerCase();
subs = loc.substr(7).split("/"); // Assume the first 7 characters are http://
//Added class="breadCrumbs" so that a style sheet can be used
      document.write("<a class=\"breadCrumbs\" href=\"" + getLoc(subs.length - 1) + "\">Home</a> " +
    delimiterStr + " ");
    a = (loc.indexOf('index.') == -1) ? 1 : 2;
    if (subs[subs.length-1].length == 0) {
    a++;
}
for (i = 1; i < (subs.length - a); i++) {
    subs[i] = makeCaps(unescape(subs[i]));
//Added class="breadCrumbs" so that a style sheet can be used
    document.write("<a class=\"breadCrumbs\" href=\"" + getLoc(subs.length - i - 2) + "\">" +
    subs[i] + "</a> " + delimiterStr + " ");
}
document.write(document.title);
}
function makeCaps(a) {
    g = a.split("_");
    for (l = 0; l < g.length; l++) {
    g[l] = g[l].toUpperCase().slice(0, 1) + g[l].slice(1);
}
return g.join(" ");
}
function getLoc(c) {
    var d = "";
    if (c > 0) {
    for (k = 0; k < c; k++) {
    d = d + "../";
    }
}
return d;
}
//-->
</script>
</head>

<body>
<!--
      Use this if you want to use an arrow image
<script type="text/javascript">breadCrumbs("<img src='ArrowRight.gif'>");</script>

-->
<br />
<script type="text/javascript">breadCrumbs(">");</script>

</body>
</html>
0
 
LVL 3

Expert Comment

by:bjrcreations
ID: 9826167
I believe Iguanasan's code assumes that each breadcrumb is a path back to the root directory. This is not always the case. You may be on "Home / HR / Announcements / Benefits /", but you could still only be in the folder "Home / HR". Best practice for breadcrumbs: what is the optimum path you want your users to travel to access this information? Then display those breadcrumbs. This often requires manually programming the breadcrumbs.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 4

Expert Comment

by:Iguanasan
ID: 9826185
bjrcreations makes a good point.  As for my code: I just gave him what he asked for.
0
 
LVL 3

Expert Comment

by:bjrcreations
ID: 9826199
Iguanasan, you are right - your code works great given his requirements.
0
 

Author Comment

by:jckwoo
ID: 9826284
Bjrcreations & Iguanasan,

Is there a way to make this work?    I should clarify that there is drop navigation bar on top of the page.   Each time you go to a folder & subfolders, the breadcrumb path changes.  
0
 
LVL 4

Expert Comment

by:Iguanasan
ID: 9826329
It does work.  I'm not sure I understand the question.
0
 
LVL 3

Expert Comment

by:bjrcreations
ID: 9826371
jckwoo,

Isn't that what you want? When you go to a folder or subfolder, it changes the path to include that folder or subfolder - right? So if you were on "Home / HR" and you click on the Announcements link (taking you to the announcements folder), you are now in "Home / HR / Announcements". If this is the case, Iguanasan's code should work.

bjrcreations
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now