Breadcrumbs PHP Class v. 2.4.4.1
If you like my script, please rate it on Hotscripts.com!
Download Files

What's New in 2.4.4.1:
  • Fixed _toSpace, specialLang, and dirFormat

What's New in 2.4.4:
  • Added the directory name to anchor titles
  • rootIndexName - Sets the root index page link for those who have a splash page and do not want the home breadcrumb to take them to the splashpage.
  • Fixed removeDirs() function to work with fileExists()
  • Changed the imagedir() function so that one can specify the image attributes. One can now specify the path to the image directory, the image type (gif, jpg, etc), border, id, name, alt, title, hspace, vspace, align, height, and width. Id, name, alt, title are all true/false variables to show or not to show. When used in conjuction with the changeName() function, the alt and title attribute will reflect the changed name, while the id and name attributes will remain the same as the directory name.
    WARNING: the format of the imagedir() function has now changed, so if you currently use this function, you will need to recode it using the new format!

What's New in 2.4.2:
  • unlinkCurrentDir - Removes the current directory link.
  • Now works with personal websites that have the username in the URL: http://www.domain.com/~username/
  • Bug fixed if you set homepage to '' and were at root it would show the spacer symbol, now it just outputs the filename.
  • Bug fixed where when removing a directory, it also removed the directory from other directory links.

What's New in 2.4.0:
  • linkFile - links the filename to itself.
  • target - targets a frameset.
  • Change the changeFileName() function so that it takes the full server path to the file instead of just the filename. This allows you to rename specific files, instead of all files with the same name.
  • Fix bug when hideFileExt and changeFileName were used together, it would break changeFileName

All examples on this page use the breadcrumbs class.

Description: Show directory and file path with links for instance like this:

home > classes > breadcrumb > index.php


Global Options Directory Options File Options
symbol
special
cssClass
_toSpace
target
homepage
rootIndexLink
unlinkCurrentDir
dirformat()
imagedir()
changeName()
removeDirs()
showfile
fileExists()
hideFileExt
changeFileName()
linkFile

Frequently Asked for Examples


Global Options

1. Symbol separator: Specify what symbols to use between your directory names.

$breadcrumb->symbol=' || ';

home || classes || breadcrumb || index.php


$breadcrumb->symbol=' <> ';

home <> classes <> breadcrumb <> index.php

2. Special formatting: I also added a "special" formatting which allows you to show the path as if Elmer Fudd wrote it, or a Hacker wrote it, or in Reverse or hey even in pig latin!

$breadcrumb->special='elmer';

home > cwasses > bweadcwumb > index.php


$breadcrumb->special='hacker';

}{0|V|3 > (L45535 > BR34D(RU|V|B > 1|\|D3X.P}{P


$breadcrumb->special='reverse';

emoh > sessalc > bmurcdaerb > php.xedni


$breadcrumb->special='pig';

omehay > lassescay > readcrumbbay > index.phpyay

3. CSS Class Style: Use a css class to define the look of your breadcrumb.

$breadcrumb->cssClass='crumb';

home > classes > breadcrumb > index.php

4. Replace Underscores: Replace underscores with spaces. Additional Example

$breadcrumb->_toSpace = TRUE;

home > classes > breadcrumb > index.php

5. Frameset Target: Target a frameset.

$breadcrumb->target = '_blank';

home > classes > breadcrumb > index.php


Directory Options

6. Homepage naming: A person can use any name for the homepage/base directory or not show it at all.

$breadcrumb->homepage='homepage';

homepage > classes > breadcrumb > index.php


$breadcrumb->homepage='';

classes > breadcrumb > index.php

7. (NEW) Set Root Index Page: Sets the root index page link for those who have a splash page and do not want the home breadcrumb to take them to the splashpage.

$breadcrumb->rootIndexLink='index2.php';

home > classes > breadcrumb > index.php

8. (NEW) Unlink Current Directory: Removes the current directory link.

$breadcrumb->unlinkCurrentDir=TRUE;

home > classes > breadcrumb > index.php
home > classes > breadcrumb

9. Case formatting: Specify the format you would like the directory names to be in, first letters uppercase, all uppercase, all lowercase, or the actual naming of your directory with no changes.

$breadcrumb->dirformat='ucfirst';

Home > Classes > Breadcrumb > Index.php


$breadcrumb->dirformat='uppercase';

HOME > CLASSES > BREADCRUMB > INDEX.PHP


$breadcrumb->dirformat='lowercase';

home > classes > breadcrumb > index.php


$breadcrumb->dirformat='ucwords'; - (Additional Example)

Home > Classes > Breadcrumb > Index.php


$breadcrumb->dirformat='titlecase'; - (Additional Example)

Home > Classes > Breadcrumb > Index.php

10. Use images: Use images in place of text for your breadcrumbs, by specifying the directory the images can be found in. You can also specify the image type (gif, jpg, etc), border, id, name, hspace, vspace, align, height, width, and alt attributes. I have also included an example of how to use an image for the separator character. If you use the changeName function along with images, the alt attribute will be the changed name, while the id and name attributes will remain the actual directory name.

$breadcrumb->imagedir=array('path' => 'images/');

home > classes > breadcrumb > index.php


$breadcrumb->imagedir=array('path'=>'images/', 'type'=>'gif', 'border'=>2, 'id'=>FALSE, 'name'=>TRUE, 'hspace'=>2, 'vspace'=>4, 'align'=>'top', 'height'=>20, 'width'=>75, 'alt'=>TRUE, 'title'=>TRUE);
$breadcrumb->symbol='<img src="/images/crumb_spacer.gif" border="0" alt="" />';

Baskettcase HomepagePHP ClassesBreadcrumbs Class


$breadcrumb->imagedir=array('path' => 'images/');
$breadcrumb->symbol='<img src="/images/crumb_spacer.gif" border="0" alt="" />';

homeclassesbreadcrumb


11. Directory aliasing: Rename your directories to whatever you would like them to show up as in your breadcrumb.

$breadcrumb->changeName=array('home'=>'Baskettcase Homepage',
                              'classes'=>'PHP Classes',
                              'breadcrumb'=>'Breadcrumbs Class');

Baskettcase Homepage > PHP Classes > Breadcrumbs Class > index.php

12. Remove Directories: Hide a directory from showing in the breadcrumb.

$breadcrumb->removeDirs=array('classes');

home > breadcrumb > index.php


File Options

13. Show filename: Specify whether or not to show the current file name, just show the path or show the path with the file name.

$breadcrumb->showfile=FALSE;

home > classes > breadcrumb


$breadcrumb->showfile=TRUE;

home > classes > breadcrumb > index.php

14. Index exists?: Set your index file name so that if the file exists then link the directory, otherwise if the file does not exist do not create a link.

This is good for those people that do not want surfers to be able to look at their directory structure if they do not have a default index page within that directory. It will still show the directory name within the breadcrumb, but it will not add a link to the directory name.

$breadcrumb->fileExists=array('index.htm','index.php','index.html');

home > classes > breadcrumb > index.php

15. Hide File Extension: Hides the filename extension

$breadcrumb->hideFileExt = TRUE;

home > classes > breadcrumb > index

16. Filename Aliasing: Change the filename to a more user friendly one.

$breadcrumb->changeFileName=array('/classes/breadcrumb/index.htm'=>'Breadcrumbs PHP Class v. 2.4.4.1');

home > classes > breadcrumb > index.php

17. Filename Linking: Links the filename to itself.

$breadcrumb->linkFile = TRUE;

home > classes > breadcrumb > index.php

It is a real easy class to implement and if you have any other ideas feel free to

Sorry, but a Javascript-enabled browser is required to email me.

.


Thank you for your donations!
Top 5 Donors
1. Beda o' Künzle
2. Mark Dale
3. James Richards
4. Jurgen Theiss
4. Michael Karagosian
4. Chris Falkenstein
5. Anand Rakish