breadcrumbs
Moderator: General Moderators
breadcrumbs
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
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
Well, there are numerous of ways. You could use something similiar to:
Just change it to fit your prefered solution...
Code: Select all
$bread = $_SERVER["SCRIPT_FILENAME"];
$crumbs = explode('/',$bread);
print_r($crumbs);- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
It's a path to follow back to where you came from - as used in fairy tales such as Hansel and Gretel.Bech100 wrote:just wondering, why are they called "Breadcrumbs"?
MacGrimms' 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.
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
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:Just change it to fit your prefered solution...Code: Select all
$bread = $_SERVER["SCRIPT_FILENAME"]; $crumbs = explode('/',$bread); print_r($crumbs);
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
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