Jump to content

breadcrumb help


foevah

Recommended Posts

I am trying to get breadcrumbs work on the footer of my site. I am using the code from this site:

http://gr0w.com/articles/code/php_br...links_creator/

 

This is how my breadcrumb.php code looks like:

<?
$ul_id='crumbs';
$bc=explode("/",$_SERVER["PHP_SELF"]);
echo '<ul id="'.$ul_id.'"><li><a href="http://www.newmedia.lincoln.ac.uk/jecgardner/">Home</a></li>';
while(list($key,$val)=each($bc)){
$dir='';
if($key > 1){
  $n=1;
  while($n < $key){
   $dir.='/'.$bc[$n];
   $val=$bc[$n];
   $n++;
  }
  if($key < count($bc)-1) echo '<li><a href="'.$dir.'">'.$val.'</a></li>';
}
}
echo '<li>'.$pagetitle.'</li>';
echo '</ul>';
?>

 

I am not sure if I should paste this line twice but change Home to Contact:

echo '<ul id="'.$ul_id.'"><li><a href="http://www.newmedia.lincoln.ac.uk/jecgardner/">Contact</a></li>';

 

On my index.php page I have put the following include code on my footer:

<?php $pagetitle="Home"; include("newmedia.lincoln.ac.uk/jecgardner/breadcrumb.php"); ?> 

 

I have put the same line above on my contact.php page but changed "Home" to "Contact"

 

<?php $pagetitle="Contact"; include("newmedia.lincoln.ac.uk/jecgardner/breadcrumb.php"); ?> 

 

When I view my site the browser gives me this error:

Warning: main(newmedia.lincoln.ac.uk/jecgardner/breadcrumb.php): failed to open stream: No such file or directory in /home/webmedia/public_html/jecgardner/index.php on line 252

 

Warning: main(): Failed opening 'newmedia.lincoln.ac.uk/jecgardner/breadcrumb.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/webmedia/public_html/jecgardner/index.php on line 252

 

Please can someone help me fix this!?

Link to comment
Share on other sites

this is where the breadcrumb.php file is:

http://www.newmedia.lincoln.ac.uk/jecgardner/breadcrumb.php

 

it does exist.. It only says Home though..

 

Should I add this line to the breadcrumb file?:

echo '<ul id="'.$ul_id.'"><li><a href="http://www.newmedia.lincoln.ac.uk/jecgardner/">Contact</a></li>';

 

and do the same for all the other pages on my site?

Link to comment
Share on other sites

This line works:

<?php $pagetitle="Contact"; include '/home/webmedia/public_html/jecgardner/breadcrumb.php'; ?>

And I added the same to my index (home) page which looks like this:

<?php $pagetitle="Home"; '/home/webmedia/public_html/jecgardner/breadcrumb.php'; ?>

 

When I view my index page I dont see any Home link on the footer?

This is where I have put the include:

<div id="footer_bl"></div>

 

I have added the following lines to the breadcrumb.php file:

echo '<ul id="'.$ul_id.'"><li><a href="http://www.newmedia.lincoln.ac.uk/jecgardner/contact.php">Contact</a></li>';
echo '<ul id="'.$ul_id.'"><li><a href="http://www.newmedia.lincoln.ac.uk/jecgardner/year2.php">Year 2</a></li>';
echo '<ul id="'.$ul_id.'"><li><a href="http://www.newmedia.lincoln.ac.uk/jecgardner/year3.php">Year 3</a></li>';

 

When you view the contact page on the footer it lists all the links (year2 and year3) but when you view the home page it doesn't even display the Home link??

Link to comment
Share on other sites

a NON-PHP related error; your html:

 

change

echo '<ul id="'.$ul_id.'"><li><a href="http://www.newmedia.lincoln.ac.uk/jecgardner/contact.php">Contact</a></li>';
echo '<ul id="'.$ul_id.'"><li><a href="http://www.newmedia.lincoln.ac.uk/jecgardner/year2.php">Year 2</a></li>';
echo '<ul id="'.$ul_id.'"><li><a href="http://www.newmedia.lincoln.ac.uk/jecgardner/year3.php">Year 3</a></li>';

 

to

echo '<ul id="'.$ul_id.'"><li><a href="http://www.newmedia.lincoln.ac.uk/jecgardner/contact.php">Contact</a></li>';
echo '<li><a href="http://www.newmedia.lincoln.ac.uk/jecgardner/year2.php">Year 2</a></li>';
echo '<li><a href="http://www.newmedia.lincoln.ac.uk/jecgardner/year3.php">Year 3</a></li></ul>';

Link to comment
Share on other sites

Ok I have changed this code in breadcrumb.php to the following:

echo '<li><a href="http://www.newmedia.lincoln.ac.uk/jecgardner/">Home</a></li>';
echo '<li><a href="http://www.newmedia.lincoln.ac.uk/jecgardner/contact.php">Contact</a></li>';
echo '<li><a href="http://www.newmedia.lincoln.ac.uk/jecgardner/year2.php">Year 2</a></li>';

 

When you view my homepage there is no Home link in the footer? But when you view the contact page it lists all of these in the footer:

# Home

# Contact

# Year 2

# Contact

 

On the contact page it should just be Home > Contact

 

Why is it showing links to all the other pages in the footer and why isnt there any link on my home page?

Link to comment
Share on other sites

Ok I am using this on my homepage:

<?php $pagetitle="Home"; include 'breadcrumb.php'; ?>

on my

and I am using this on my contact page:

<?php $pagetitle="Contact";  include '/home/webmedia/public_html/jecgardner/breadcrumb.php'; ?>

Both seem to be ok but each page now lists all the links in the footer that I have  added into the breadcrumb.php file.

 

On my home page I just want it to display: Home

On the contact page footer I want it to look like this: Home > Contact

 

Why does the home page and contact page both show all the links on the footer??:

  • Home
  • Contact
  • Year 2

 

This is how the breadcrumb.phps looks like:

<?
$ul_id='crumbs';
$bc=explode("/",$_SERVER["PHP_SELF"]);
echo '<li><a href="http://www.newmedia.lincoln.ac.uk/jecgardner/">Home</a></li>';
echo '<li><a href="http://www.newmedia.lincoln.ac.uk/jecgardner/contact.php">Contact</a></li>';
echo '<li><a href="http://www.newmedia.lincoln.ac.uk/jecgardner/year2.php">Year 2</a></li>';
while(list($key,$val)=each($bc)){
$dir='';
if($key > 1){
  $n=1;
  while($n < $key){
   $dir.='/'.$bc[$n];
   $val=$bc[$n];
   $n++;
  }
  if($key < count($bc)-1) echo '<li><a href="'.$dir.'">'.$val.'</a></li>';
}
}
echo '<li>'.$pagetitle.'</li>';
echo '</ul>';
?>

Link to comment
Share on other sites

ok its nearly working.. I would like to ask a few more questions:

 

The footer on my homepage repeats Home twice (Home > Home) to make it say one Home I deleted $pagetitle="Home" from:

<?php $pagetitle="Home"; include '/home/webmedia/public_html/jecgardner/breadcrumb.php'; ?>

 

I dont know if this is cheating or acceptable to delete $pagetitle="Home" so it says Home once. I have left the pagetitle in place so you can see what I mean CLICK HERE and scroll to the footer to see what I mean!

 

The contact page, year 2 and year 3 pages breadcrumb seem to be working fine :)

 

However I have another problem when I try to add the breadcrumb to my comments page. This is because my comments page (journal.php) is inside a folder and not on the root directory.

 

This is the code I added to the comments footer:

<?php $pagetitle="Comments"; include '/home/webmedia/public_html/jecgardner[u]/entry/[/u]breadcrumb.php'; ?> 

 

This is what displays on the comments page:

Home > jecgardner

Comments

 

Why is it showing jecgardner? I have tried linking the breadcrumb like I have on all the other pages and I have also added the same breadcrumb file into the entry folder which is shown above. Any ideas how to fix this please?

 

I have one more question! Which is about the arrow (>) I have added in the breadcrumb.php file:

echo ' > '.$pagetitle.' ';

I was wondering how to not have the arrow appear on the home page? It looks ok on all the other pages Home > Contact.. But Home > wouldnt make sense? Is there a way around this?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.