This morning I just started hard coding the breadcrumb navigation into each page. However I just realized what happens when I need to change a URL name or folder name. Then I have to go through and change all the breadcrumbs too. That's no good. How do I do this so that the php just magically populates the title or the URL into the breadcrumb? I have not been able to find much on google for this?
Here is a php script I will try http://www.baskettcase.com/classes/breadcrumb/
Anyone else used any other you can point me too?
Here is another promising one. http://papermashup.com/how-to-display-breadcrumbs-on-your-site-using-php/. Can you look at this? D I have to add the main but above my doctype. Or does it not mater where?
Same deal for this php script. http://www.whitford.id.au/webmonkey/code/breadcrumbs/position_crumbs/php.php
Do I have to add this line above the doctype or no?
?php include ( $SERVER['DOCUMENTROOT'] . '/includes/functions.php'); ?
Bueller... Bueller... Bueller...?
How is the hierarchical relationship of the pages stored in the database?
How are your urls build? www.example.com/page1/subpage1/subpage2/ etc or more like index.php?id=1
Hey guys thanks for the reply. No database and the structure is like the following. There are many different folder names however.
You have to add this to every php document where you wish to use the breadcrumbs. You don't need to add it above your doctype per se. I would place the breadcrumbs function in a file and include this file in your php pages where you include your other files. If you have no includes yet, just put it in the top of your php file.
Uhhhmmm... You just showed me how to include a include. Pretty sure I got that one covered. I need the function part.
Apparently I'm the first in this forum to implement a beadcrumbs nav. Got to say I have not been getting much help lately. My forum post have turned into more akin to my spit balling board. A place I think out loud and solve things myself.
Here is the best script I could find for those reading this in the future. It gives you every possible configuration you could think of. It's a bit heavy though. I'm currently looking for a smaller script. But it will do fine if Ali don't find it. http://www.baskettcase.com/classes/breadcrumb/
How many pages are there and how many "levels" deep will it go? If there's only a handfull of pages and a change of location is going to be rare then php may be overkill for generating the bread crumbs. Is there a CMS i use?
Outputting a breadcrumb trail infers that there is some kind of relationship between parent pages and children (or grandchildren) pages.
You have not described what that relationship is and how you store it.
It could be done in a database, here is a contrived example of how 2 pages might relate to each other in the db.
++++++ and example row +++++++++
id | 4
parent_id | 1
title | About us
url | about-us
++++++ another row +++++++++
id | 12
parent_id | 4
title | How to find us
url | find-us
That could be pulled out to give
<a href=/>Home</a> <a href=/about-us.php>About us</a> | <a href=/find-us.php>How to find us</a>
OR the relationship might be defined by files in folders.
And a similar url breadcrumb could be generated by using file reading functions as well as sstr_replace() and ucwords().
If you explain how you establish one page knows what its parent is, and someone will try and help you make a breadcrumb from that.
Until you do that we would be shooting in the dark, hence nobody can a helpful comment which addresses your particular situation.
Duh, now I see you have started another thread .... and how you are using the file system ....
I figured it out in the other thread
This topic is now closed. New replies are no longer allowed.