Breadcrumbs

software development

#1

Hi there. I want to add breadcrumbs to my site, but I don’t want to have to individually code each page to add them. Does anyone know where I can find a crash course in breadcrumbs? I have done a bit of programming in the past, but I’m not familiar with ASP or the like, so it would have to be from the ground up. Thanks.


#2

You’d have to ensure all your pages are interpreted as php for it to work and would have to add a snippet to each page anyway . . . but it would be self-maintaining after that. How’s this: http://www.zend.com/zend/spotlight/breadcrumb28.php

<img src=http://theprawn.com/img/?tx1=Random Quote:&tx2=rand&zx=600&zy=60&tr&cf=000000255&qf=http://theprawn.com/img/quotes />


#3

Okay, I tried this out and I’ve definitely made headway. I’ve run into a couple of problems though.

First, unless I’m mistaken, everytime I want to add a new directory or, more importantly, move a folder, I would have to edit the array of folder names in each individual file - I’m trying to avoid this. How would I get the code with the array as an external file that could just be referenced by every page? I was trying out another set of code from this page which just uses folder names instead of an array of replacement names (since I name all my folders according to content, this is fine for me):

http://evolt.org/article/Breadcrumbs_for_PHP_Lovers/17/4455/

Problem is, I can’t get it to work - I end up with warnings and almost no content. My test page using the code from that site is here:

http://www.yetiboy.ca/colombia/albums/panama/monday/test.php

Second, when I click on any of the directory links in the breadcrumb trail using the code on the page you suggested to me I end up getting an index of the files in that directory instead of index.html showing up. How can I get around this? As well, in order to have breadcrumbs on each page I won’t be able to use index.html anymore, I would have to use index.php (or some other filename); how can I designate what file is opened when it goes to that folder?

Thanks for the help so far!

brad


#4

Put the array in another php document. You can import it into your document using
include “fileName.php”;
–It will process fileName.php as if it were in that document. It actually looks like that’s what they tried to do . . .

About your page, I can’t actually see the php source so I can’t say for sure what may or may not be wrong–but a few things I can deduce. First error, is it’s trying to import a file “breadcrumb.php”, it looks like–presumably the file that will house the php code so you don’t have to rewrite it every page. Since that doesn’t exist, it’s getting an error. Then, it tries to call breadcrumb() – a function that doesn’t exist because it, presumably, was defined in breadcrumb.php.

You can define what pages (and in what order they’re looked for) to use for your index via .htaccess. If you already have one (in your web/public directory), open it up; if not, just make a plain text file. Either way, you want a line in there that reads
DirectoryIndex index.php index.shtml index.html index.htm
(You can, of course, change/add to/remove from that list at will). Save it as .htaccess and voila.


#5

Working perfectly now, thanks for all your help!

brad


#6

Looks great; didn’t take you long at all :slight_smile:


#7

Thanks - helps that it’s a pretty small site at this point :slight_smile: