Jump to content

Recommended Posts

[a href=\"http://www.zend.com/zend/spotlight/breadcrumb28.php\" target=\"_blank\"]http://www.zend.com/zend/spotlight/breadcrumb28.php[/a]

[a href=\"http://www.baskettcase.com/classes/breadcrumb/\" target=\"_blank\"]http://www.baskettcase.com/classes/breadcrumb/[/a]

have fun
Link to comment
https://forums.phpfreaks.com/topic/12947-bread-crumbshowto/#findComment-49893
Share on other sites

[!--quoteo(post=388522:date=Jun 27 2006, 07:45 AM:name=SharkBait)--][div class=\'quotetop\']QUOTE(SharkBait @ Jun 27 2006, 07:45 AM) [snapback]388522[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Ah thanx for the replies. I guess I'll have to do a combination of it.

directory and file ;) I'll play around and see what I can come up with with help of the examples you guys have posted.
[/quote]

This is what I came up with:

(how I wish php tags were working ;))
[code]
<ul id="breadcrumbs">
<?php
// Get Directory Path and Scriptname to create BreadCrumbs
$parts = explode("/", dirname($_SERVER['PHP_SELF']));
echo "<li><a href=\"/\"Home</a> ";
foreach($parts as $key => $dir) {
  $label = ucwords($dir);
  $url = "";
  for($i = 1; $i <= $key; $i++) {
    $url .= $parts[$i]."/";
  }
  if($dir != "") {
    echo "<li>> a href=\"/{$url}\">{$label}</a></li> ";
  }
}
$script = explode(".", basename($_SERVER['PHP_SELF']));
if(script != "") {
  echo "<li>> ". ucwords($script[0])."</li>";
}
?>
</ul>
[/code]

Thanx to the sillybean.net example and suggestions :) My Breadcrumbs look like:

Home > Admin > ScriptName
Link to comment
https://forums.phpfreaks.com/topic/12947-bread-crumbshowto/#findComment-50116
Share on other sites

  • 4 months later...
Hi all,

I'm also using the Sillybean example. It's quite easy to use but I still have a question. What if I need to remove, or not display, the two first directories. For example, I would like to remove Home and Dir1 from:

Home > Dir1 > Dir2 > Dir3 > Here

Removing Home is easy, just commenting out, but how about Dir1? If I use unset ($parts[1]), it removes Dir1 from the breadcrumb but then the links are wrong.

Thanks
Matt
Link to comment
https://forums.phpfreaks.com/topic/12947-bread-crumbshowto/#findComment-124448
Share on other sites

it's hard to determine how to fix that without you showing your code, but if it's because of some kind of loop you are doing that is dependant on the array keys being 12345 instead of 1245 then you can use [url=http://www.php.net/array_values]array_values()[/url] to reset the keys after you have unset one of them.  consider this example:

[code]
<?php
  // example array
  $blah = array('a','b','c','d','e');
 
  // display what the key - value initially looks like
  // will show keys 0,1,2,3,4
  foreach ($blah as $key => $val) {
      echo "$key - $val <br>";
  }
 
  // unset the middle element
  unset ($blah[2]);

  // show what the key-val looks like now
  // shows 0,1,3,4
  foreach ($blah as $key => $val) {
      echo "$key - $val <br>";
  }

  // reset the keys
  $blah = array_values($blah);

  // display results from reseting the keys
  // shows 0,1,2,3 
  foreach ($blah as $key => $val) {
      echo "$key - $val <br>";
    }
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/12947-bread-crumbshowto/#findComment-124556
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.