Bread Crumb Trails
Moderator: General Moderators
-
montecristo
- Forum Newbie
- Posts: 20
- Joined: Thu Oct 19, 2006 9:51 am
Bread Crumb Trails
Hi Guys,
I am looking to add a breadcrumb trail to my site so if a person clicks on page 1 then goes to page 2 and on page 2 chooses to go to page 4, I want my trail to look like
page 1 > page 2 > page 4
Now I tried to use session variables to build up the path dynamically, but if a user refreshes the page it screws things up.
I also looked at some Javascript options, but the ones I looked at just breakup the url into bread crumb trails eg:
If I am looking at http://localhost/xampp/mypage.php
The Javascript returns
localhost > xampp > mypage.php
( I also saw some php classes that do the similar thing : http://www.baskettcase.com/classes/breadcrumb)
Now what I am thinking of doing is writing a php function, where you pass in the current page name, check to see if is in the path, if it is, don't add it, if it is isn't do, add it.
Any ideas on this would be great as it is begining to annoy me alot
Thanks
I am looking to add a breadcrumb trail to my site so if a person clicks on page 1 then goes to page 2 and on page 2 chooses to go to page 4, I want my trail to look like
page 1 > page 2 > page 4
Now I tried to use session variables to build up the path dynamically, but if a user refreshes the page it screws things up.
I also looked at some Javascript options, but the ones I looked at just breakup the url into bread crumb trails eg:
If I am looking at http://localhost/xampp/mypage.php
The Javascript returns
localhost > xampp > mypage.php
( I also saw some php classes that do the similar thing : http://www.baskettcase.com/classes/breadcrumb)
Now what I am thinking of doing is writing a php function, where you pass in the current page name, check to see if is in the path, if it is, don't add it, if it is isn't do, add it.
Any ideas on this would be great as it is begining to annoy me alot
Thanks
There isn't just some magic function or code snippet to do breadcrumbs. The solution depends on the framework you are using or how you have your pages setup. So I guess start there, how do you have all your pages setup? Are they just a bunch of random PHP pages than you can get through by a bunch of different links? Are you using some sort of MVC? etc.
-
montecristo
- Forum Newbie
- Posts: 20
- Joined: Thu Oct 19, 2006 9:51 am
-
impulse()
- Forum Regular
- Posts: 748
- Joined: Wed Aug 09, 2006 8:36 am
- Location: Staffordshire, UK
- Contact:
I came across this in a book I was reading a couple of weeks ago. Basics of it are to create an associative array for each directory with a few properties including: directory name, url and parent directory.
I'm not sure the legalities of scanning the page and hosting it. If you want it, let me know and I'll send it to you.
I'm not sure the legalities of scanning the page and hosting it. If you want it, let me know and I'll send it to you.
-
montecristo
- Forum Newbie
- Posts: 20
- Joined: Thu Oct 19, 2006 9:51 am
I would really appreciate that impulse().
I will send you my email address and if you could send me the info, that would be brilliant.
As I said, in my first post, I was thinking of creating a function that would add the page to the trail if it wasn't already there and if it was, it wouldn't add it (This gets around the problem of using session variables and a user refreshing the page)
I will post it up here when I have finished it, done a bit of testing on it and it seems to work for me.
Thanks again
I will send you my email address and if you could send me the info, that would be brilliant.
As I said, in my first post, I was thinking of creating a function that would add the page to the trail if it wasn't already there and if it was, it wouldn't add it (This gets around the problem of using session variables and a user refreshing the page)
I will post it up here when I have finished it, done a bit of testing on it and it seems to work for me.
Thanks again
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
just check if the page is the last spot in the array already:
Code: Select all
if($breadcrumb[count($breadcrumb)-1]!=$this_page) $breadcrumb[]=$this_page;- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
viewtopic.php?t=37771 could be of interest.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
You'll have a tough time if you attempt to use the "find all posts by feyd" link in my profile. phpBB decides to kill itself after a page or so into the list.matthijs wrote:Sorry to interrupt, but that's a cool piece of code you linked to feyd. I just decided that if I find the time I'm going to read all your posts.
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact: