GIDForums

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum > PHP Code Library
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 09-Jan-2006, 21:59
crystalattice's Avatar
crystalattice crystalattice is offline
Senior Member
 
Join Date: Apr 2004
Location: Hawaii
Posts: 1,521
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);
                }
            }
        }
    }
}
            
makeBreadcrumbs($_SERVER["PHP_SELF"]);
?> 

__________________
Common Sense v2.0-Striving to make the world a little bit smarter.
 

Recent GIDBlogGoing to Iraq by crystalattice

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 4 28-Oct-2005 11:50
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 07:58

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 13:31.


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