php breadcrumbs

making a breadcrumb trail in php


A breadcrumb navigation can have a structure based on 3 different types - path, attribute, and location.

The path type breadcrumbs are dynamic and display the pages used by the visitor to reach the current pages. If, for example, our visitor browsed from page C to page A and then to B the trail will look something similar to this: C > A > B in which "B" is the current page and C > A is the navigation used by our visitor

The attribute type of breadcrumbs will display all types of reaching our page B and our result will show many different trails representing all the possible ways of reaching that page.

The location type of breadcrumbs will display the site structure based on category trees. This is very well used in web directories, ecommerce websites and almost everywhere we have multiple categories.


google search results

1. mindpalette.com: breadcrumbs tutorial,
PHP Breadcrumb Links. By: Nate Baldwin.
This tutorial and script will use PHP to read where your page is in the site folder structure and build...

This script works fine . . . but
  1. it doesn't display current page url
  2. the 'crumbs' aren't linked -just 'HOME'
  3. directory names are capitalized, but that can be changed

Download the 'backlinks.php', then upload to the root level of your server. Then, on the page where the links are to appear (with a .php extension), paste in this PHP code into the source code of your page wherever you'd like the links to appear:
<?php include($_SERVER['DOCUMENT_ROOT']."/backlinks.php"); ?>


2. www.roscripts.com
Path based.
The key to using this is to decide on a $level for each page. (array, starting position 0) This determines where in the trail a link will be placed. So, I normally make the homepage level 0, then every page that can be accessed from the top level nav becomes level 1, and every page from that second level becomes level 2, and so on. When users return to a higher level (e.g. level 1) the surplus links are removed. Only one page can occupy a $level in the crumb trail. There might be several routes to a page. In which case, the trail will reflect the route that the user actually took to get to that page.


3. Breadcrumbs PHP Class v. 2.4.4.1
consider a donation


4. sillybean.net: absurdly simple php breadcrumbs, 2004