picnictutorials — 2013-02-18T15:52:24-05:00 — #1
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?
picnictutorials — 2013-02-18T16:06:27-05:00 — #2
picnictutorials — 2013-02-18T16:49:31-05:00 — #3
Here is a php script I will try http://www.baskettcase.com/classes/breadcrumb/
Anyone else used any other you can point me too?
picnictutorials — 2013-02-18T16:54:27-05:00 — #4
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?
picnictutorials — 2013-02-18T16:58:50-05:00 — #5
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...?
spacephoenix — 2013-02-19T02:04:24-05:00 — #6
How is the hierarchical relationship of the pages stored in the database?
rvand85 — 2013-02-19T03:53:07-05:00 — #7
How are your urls build? www.example.com/page1/subpage1/subpage2/ etc or more like index.php?id=1
picnictutorials — 2013-02-19T06:41:19-05:00 — #8
Hey guys thanks for the reply. No database and the structure is like the following. There are many different folder names however.
rvand85 — 2013-02-19T09:49:11-05:00 — #9
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.
picnictutorials — 2013-02-19T11:41:29-05:00 — #10
Uhhhmmm... You just showed me how to include a include. Pretty sure I got that one covered. I need the function part.
picnictutorials — 2013-02-19T17:31:08-05:00 — #11
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/
spacephoenix — 2013-02-20T02:18:10-05:00 — #12
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?
cups — 2013-02-20T05:14:39-05:00 — #13
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.
cups — 2013-02-20T05:17:14-05:00 — #14
Duh, now I see you have started another thread .... and how you are using the file system ....
picnictutorials — 2013-02-20T08:29:02-05:00 — #15
I figured it out in the other thread