idea/ concept behind creating breadcrumbs

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi everybody,

I want to create dynamic breadcrumbs for a site I am developing. I just
want to get some views about the algorithm of breadcrumbs.

The way I look at it is the concept of parent/ child (main/ sub). I
have the "Home" page, which has links to sub-pages such as
"Introduction", "History", "Timetable", etc. Each page can have other
sub-pages, such as "Timetable" can have "Semester1", "Semester2", etc.
This is how I'd initially think. Am I on the right track? If yes, how
do I proceed? Do I need a database or is there another efficient way to
do it? If it is in fact the way I am thinking, then I think I need a
way to "register" or hold the data in some way and access it on each
page. I'm just lost here.

Please push me to the right direction.


Re: idea/ concept behind creating breadcrumbs wrote:

Quoted text here. Click to load it

Hi, you can use _GET for this, easiet way is like
index.php?cat=$cat&sub=$sub&id=$id for as many depths as needed, you
just need to make sure each link on your page adds/removes the required
strings. you could use numbers or names, i use names in mine so i dont
need to have a database and i can capatilise the first letter of the
word and remove underscores ect so it tidies it up when display the


Re: idea/ concept behind creating breadcrumbs

Well if you have a database then that would be a good place to start.
If you are not currently using a database you could store the
relationships in an include file and include_once it into each page.

For a database I would do something like:


Then use a recursive function to "walk" up and down the tree:

function printnode($node) {
 if ($node->parent_id) {
 echo $node->pagename;

This is an oversimplification obviously but you get the idea. The page
needs to call printnode(getNode(PAGE ID)) to print it's path. getNode
is not shown here but it takes the ID as a parameter and returns an
object with the information returned from the database. You could also
store the relationship like this:

$pagedata = array(
1 => array('pagename',parid),
2 => array(...),

Hope I explained clearly enough and answered your question.

-Robert wrote:
Quoted text here. Click to load it

Re: idea/ concept behind creating breadcrumbs

rlee0001 wrote:
Quoted text here. Click to load it

If you want breadcrumbs, with a hierarchical table, it might be worth it to
use the nested set model instead of the adjacency model:

Rik Wasmus

Re: idea/ concept behind creating breadcrumbs

I've always thought of breadcrumbs as a representation of where you
have been, to answer the wuestion 'How did I get here?'. A kinda fancy
way to show a users history within your website's domain. Breadcrumbs
are named such as a reference to the fairy tale of hansel & gretal
(spell?). They left breadcrumbs on the trail the took to know how to
get back....

What you are talking about I would call a directory or page heirarchy. wrote:
Quoted text here. Click to load it

Re: idea/ concept behind creating breadcrumbs

Colin wrote:
Quoted text here. Click to load it

Well I think these are the two varieties that bread crumbs come in. I
guess which one an author chooses is based on his own tastes and how he
expects his site to be used.

Personally I find history-based breadbrumbs pointless. Why do I need a
link to where I've already been? Wouldn't I just use the back button?

Heirarchy breadcrumbs are very useful not only for navigation but also
for orientation.


Quoted text here. Click to load it

Re: idea/ concept behind creating breadcrumbs

On Fri, 21 Jul 2006 09:57:33 -0700, Colin wrote:

Quoted text here. Click to load it

See, now, I've always interpreted breadcrumbs to be a fixed directory
hiearchy, and have nothing to do with the user's current browsing session.

Home > Products > Gizmos > Rotating Sprockets

Makes sense to me that that thing there is a representation of the
website's hiearchy.

Although I can understand the "user's current browsing session" type of
breadcrumb implementation.

Of course, the two styles of breadcrumb require quite different

Also, one of the things I don't like about the "current session" style of
breadcrumb is the logic problems: what happens when I browse from "Home"
to "Gizmos" to "Right Handed Doohickeys" and then back to "Gizmos"?  But
just clicking on links, not using the breadcrumb itself.  Does the
breadcrumb look like this?:

Home > Gizmos > Right Handed Doohickeys > Gizmos

Huh? What then? Also, what if the person comes in directly to the Right
Handed Doohickeys page from an outside page, say, a search?  Does "RHD's"
get the top billing in the breadcrumb?


Right Handed Doohickeys

For me, those sorts of issues make it most sensible to stick with the
"breadcrumb as website hiearchy" model.

Also, on that note, the "breadcrumb" need not necessarily have anything to
do with the "URL".  When I have implemented breadcrumbs, it has always
been with the use of a data flag -- in a database or in the page code --
that indicates, "This page's parent page is XXXX".  In the case of
"Rotating Sprockets" or "Right Handed Doohickeys", the flag would be equal
to "Gizmos" (or, rather, the unique identifier for the page "Gizmos").

Using "parent page" identifiers, one can build the breadcrumb recursively
all the way back up to "Home".



Re: idea/ concept behind creating breadcrumbs

I built a system a couple years ago and encountered these issues as  
well.  I began to see links in a web site as a directed graph  
( ).  Breadcrumbs then become  
semantically meaningful subgraphs.  The meaning is the god's eye view  
(webmaster's) and provided as a navigational aid to users.  It's not at  
all the same as what the user actually did to get from A to B (which may  
have been a terribly convoluted route).  It's also not meant to be a  
comprehensive fully-connected graph (there may be many ways to reach  
certain pages, but you select only the more important ones as breadcrumbs).

So "breadcrumb" is really a poor name for this thing.  A cairn-marked  
trail is probably more accurate.

I settled on a recursive method which allows the webmaster to fully  
control the tree (move things around, add nodes, delete subtrees, etc.)

Because of this potential for movement, I decided also -- deliberately  
-- not to encode the page's hierarchy anywhere in its URL.  Best to make  
the URL blind to the breadcrumb navigation in my experience.  Give every  
page a unique numerical identifier, I think, but make it flat.

JDS wrote:
Quoted text here. Click to load it

Re: idea/ concept behind creating breadcrumbs

JDS wrote:
Quoted text here. Click to load it

What about situations where a page can have multiple parent's
i.e a product could be under a 'On Sale' section and under its stardard
product type section

As a sidepoint, I'm not trying to defend the use of history style
breadcrumbs, just point them out as an alternative that SOME have used.
Honestly, i find history-style breadcrumbs pointless. Just use the back
button (as someone else has mentioned).
Another modern alternative has been the use of TAGS to associate items
within not conflicting groups. i.e. a product can be in multiple groups
that are not of the same hierarchy.

the whole subject we are talking about here is called (or at least I
would call it) Information Architecture (O'reilly has a book on this
subject called "Information Architecture for the Web")

Re: idea/ concept behind creating breadcrumbs

Colin wrote:
Quoted text here. Click to load it

I once did a site where peer navigation was expected at multiple
levels.  So I did a nav bar something like this

toplevel1  TOPLEVEL2  toplevel3
level2choice1  level2choice2  level2choice3  LEVEL2CHOICE4
L2C4OPTION1 l2c4option2

In this example, user went home-->level2--->choice4--->option1.

Site Timeline