Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum > PHP Code Library
User Name
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
Thread Tools Search this Thread Rate Thread
Old 09-Jan-2006, 22:59
crystalattice's Avatar
crystalattice crystalattice is offline
Aspiring author
Join Date: Apr 2004
Location: Japan (again)
Posts: 1,671
crystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nicecrystalattice is just really nice

PHP "breadcrumbs" script

Found this as part of the very useful The Grand Fandango PHP package. The package also includes What's New, What's Updated, and Navigation scripts. The Navigation script is especially nice since it's dynamic based on the folders you have on your web server. It's also GPLed.

This "breadcrumbs" script will automatically show where the user is in your directory tree in relation to Home.
PHP Code:

<!-- <alexpounds:noList /> -->


include_once($_SERVER["DOCUMENT_ROOT"] . "/gfFunctions.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/userinfo.php");

function makeBreadcrumbs($path) {
    $pathEntries = explode("/", trim($path));
    global $myExtension;
    if (preg_match("%^/$%", trim($path)) || preg_match("%^/index\." . $myExtension . "$%", trim($path))) {
        // It's the top dir. 
        echo "Home"; 
    } else {
        echo "<a href=\"/\">Home</a>";
        $currentPath = "/";
        for ($i = 0; $i < count($pathEntries); $i++) {
            if ($i < count($pathEntries)-1) {
                if (!empty($pathEntries[$i])) {
                    echo " &gt; ";
                    $currentPath .= $pathEntries[$i] . "/";
                    if (trim($path) == $currentPath . "index." . $myExtension) {
                        echo getDirName($pathEntries[$i]);
                    } else {
                        echo "<a href=\"" . $currentPath . "\">" . getDirName($pathEntries[$i]) . "</a>";
            } else {
                if (!(is_dir($_SERVER["DOCUMENT_ROOT"] . $path) || preg_match("%/index\." . $myExtension . "$%", trim($path)))) {
                    echo " &gt; ";
                    echo getPageName($_SERVER["DOCUMENT_ROOT"] . $path);

Start Programming with Python-A beginner's guide to programming and the Python language.

Interested in pen & paper role playing games from the "golden age" of gaming? Visit Old School Role-Playing Games

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP script to show last referrer url and top referrer to your site jrobbio MySQL / PHP Forum 6 22-May-2006 01:06
i need to find a PHP login/register script djd@n MySQL / PHP Forum 3 28-Oct-2005 08:19
How to call a binary from a php script akanksha_govil MySQL / PHP Forum 2 26-Jul-2005 10:09
All the big PHP script collections that matter jrobbio MySQL / PHP Forum 5 06-Jun-2003 16:14
VALIDATING file types on an PHP upload script? JdS MySQL / PHP Forum 0 02-Jan-2003 08:58

Network Sites: GIDNetwork · GIDApp · GIDBlog · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 04:43.

vBulletin, Copyright © 2000 - 2018, Jelsoft Enterprises Ltd.