View Full Version : Breadcrumbs

02-08-2010, 03:12 PM
I want to add breadcrumbs to my site and came across this code. As I use php includes for my header, left nav and footer this fits really well
Method One:
if (isset($folder) && !isset($folder2)) {
echo "<a href=\"/\">Home</a> > <a href=\"./\">$folder</a>";
if (isset($folder) && isset($page) && isset($folder2)) {
echo "<a href=\"/\">Home</a> > <a href=\"../\">$folder</a> > <a href=\"./\">$folder2</a>";
With this method, you enter this entire code within your header.php file, then in each page add the folder variables:
$folder = 'Internet Marketing';
$folder2 = 'SEO';
For each extra layer you must add additional code, just follow the same procedure as the above code has and it will work.

My problem is it doesn't seem to work! I put the code that goes in the header, the actual display code, in an html block in the header and added the $folder definitions to the include html block in the page.

Can anyone help and figure either why this doesn't work or what I've done wrong.

Appreciated, Thanks

02-08-2010, 05:03 PM
Not sure on the one above. But this one is worth a look. Just paste it in a html box, & thats it.


//Bread crumb script - Kevin Lynn Brown
//Duplicate directory names bug fix by JavaScriptKit.com
//Visit JavaScript Kit (http://javascriptkit.com) for script

var path = "";
var href = document.location.href;
var s = href.split("/");
for (var i=2;i<(s.length-1);i++) {
path+="<A HREF=\""+href.substring(0,href.indexOf("/"+s[i])+s[i].length+1)+"/\">"+s[i]+"</A> / ";
path+="<A HREF=\""+href.substring(0,href.indexOf(s[i])+s[i].length)+"\">"+s[i]+"</A>";
var url = window.location.protocol + "//" + path;

02-08-2010, 09:16 PM
Thanks - I've tried a few like this but they take the page names - what the one I put up in the post above uses page names you set yourself - it's semi-manual but means you have control over the breadcrumb names.

Hey - London Borough of Barnet - way back when i lived in the UK I bought a TVR at John Britain Motors - he won't be there anymore but on the test drive he took it up to 100mph on the A1 - I bought it immediately - cost me 880pounds! Great car - what a blast!


02-09-2010, 05:46 AM
Ah! the odd thing about it is there has been a TVR Centre/garage on Barnet lane, Arkley for as long as i can remember. But was recently changed to Trimar Sports cars (http://www.tvr-centre.co.uk/), i wonder if this is the same garage be pass on down the years? Link to John britten (http://www.brdc.co.uk/John-Britten-1931-2009)

At least it bumps the post back up for someone with a bit more php knowledge. http://www.vodahost.com/vodatalk/images/icons/icon12.gif