Page 1 of 1
breadcrumbs
Posted: Tue Sep 09, 2003 12:02 am
by ericsodt
I have looked on the site and could not find anything to do with Breadcrumbs... can someone PLEASE help me out. I am looking for a way to create them and display something like:
main > page1 > page2 > etc... etc...
How do I find the file paths I have seen people us $PHP_SELF, but that did not work for me... any clues would be greatly appreciated
Thanks
Posted: Tue Sep 09, 2003 2:10 am
by JAM
Well, there are numerous of ways. You could use something similiar to:
Code: Select all
$bread = $_SERVER["SCRIPT_FILENAME"];
$crumbs = explode('/',$bread);
print_r($crumbs);
Just change it to fit your prefered solution...
Posted: Tue Sep 09, 2003 3:27 am
by JayBird
just wondering, why are they called "Breadcrumbs"?
Mark
Posted: Tue Sep 09, 2003 3:46 am
by JAM
Leaves a trail... Kinda like a "You are here" mark.
This forum has an excellent example:
The PHP Forums Forum Index -> PHP - Normal -> etc.
Using it with a path, exploding the / make s a good start for such.
/www/coding/php/security/sessions
/www/coding/asp/snippets/
Posted: Tue Sep 09, 2003 5:30 am
by twigletmac
Bech100 wrote:just wondering, why are they called "Breadcrumbs"?
It's a path to follow back to where you came from - as used in fairy tales such as
Hansel and Gretel.
Grimms' Fairy Tales wrote:Just wait, Gretel, until the moon rises, and then we shall see the crumbs of bread which I have strewn about, they will show us our way home again.
Mac
Posted: Tue Sep 09, 2003 7:30 am
by ericsodt
Jam,
This works for the first page but does not continue onto the other pages
"Array ( [0] => " is what I get on all my pages... Somehow the path is not getting into the array
Such as when I go from page1.php to page2.php, the array does not grow... any help would greatly be appreciated
JAM wrote:Well, there are numerous of ways. You could use something similiar to:
Code: Select all
$bread = $_SERVER["SCRIPT_FILENAME"];
$crumbs = explode('/',$bread);
print_r($crumbs);
Just change it to fit your prefered solution...
Posted: Tue Sep 09, 2003 7:39 am
by twigletmac
What do your page paths look like? There is no one-size fits all solution for breadcrumb trails. You may find that your link structure neccessitates the use of sessions to keep track of users activity.
Mac
Posted: Tue Sep 09, 2003 10:10 am
by m3rajk
in a forums setting, you can do that via the get string with relative ease... but... not sure about how to do it in your setting since i don't really know how the struture of the site is
Posted: Tue Sep 09, 2003 10:25 am
by JAM
I can only show you examples, and let you work from there:
Code: Select all
<?php
// a slice of my bread
$bread = '/couriers/gods/jam/www/code/example.php';
// make crumbs, removing the first char (workaround for empty array 0)
$crumbs = explode('/',substr($bread,1));
// remove the filename
$removed = array_pop($crumbs);
// print the crumbs, then the page...
print_r($crumbs);
echo $removed;
?>
Returns:
Array
(
[0] => couriers
[1] => gods
[2] => jam
[3] => www
[4] => code
)
example.php