Page 1 of 1
Bread Crumb Trails
Posted: Thu Jan 04, 2007 6:29 am
by montecristo
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
Posted: Thu Jan 04, 2007 8:52 am
by Begby
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.
Posted: Thu Jan 04, 2007 9:14 am
by montecristo
Thanks for getting back to me,
Well some of the pages are categorized, for example there is a user object, you can search by id, name, phone etc
The others would be stock, eg. search by stock id, stock name etc
So you basically hop from one customer page to another using links.
Posted: Thu Jan 04, 2007 9:40 am
by impulse()
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.
Posted: Thu Jan 04, 2007 10:30 am
by montecristo
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
Posted: Thu Jan 04, 2007 10:45 am
by impulse()
PM me your e-mail address.
Posted: Thu Jan 04, 2007 11:06 am
by Kieran Huggins
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;
Posted: Thu Jan 04, 2007 11:17 am
by feyd
viewtopic.php?t=37771 could be of interest.
Posted: Thu Jan 04, 2007 3:01 pm
by matthijs
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.
Posted: Thu Jan 04, 2007 3:04 pm
by feyd
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.
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.

Posted: Thu Jan 04, 2007 3:07 pm
by Kieran Huggins
feyd: 24.06 posts per day... on average!
In the words of the mighty Keanu Reeves:

whoa!
Posted: Thu Jan 04, 2007 3:18 pm
by feyd
Kieran Huggins wrote:feyd: 24.06 posts per day... on average!
In the words of the mighty Keanu Reeves:

whoa!
It used to be around 30.
