Posted By

stewartduffy on 05/31/11


Tagged

php function loop breadcrumb


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

winthropite


Breadcrumb function


 / Published in: PHP
 

Function to print breadcrumb links

  1. /*
  2.  * Function to create breadcrumbs (Even for pods)
  3.  *
  4.  */
  5. function loopCrumb(){
  6. $url_string = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
  7. $url_explode = explode("/", $url_string);
  8. $i=1;
  9. $count = count($url_explode);
  10.  
  11. foreach ($url_explode as $value) {
  12. if($value != ""){
  13. $array = array_slice($url_explode, 0, $i);
  14. $url = implode("/", $array);
  15. $title = str_replace("-", " ", $value);
  16. $title = ucwords($title);
  17. $title = ucwords(strtolower($title));
  18. if ($i === 1){
  19. $title = "Home";
  20. }
  21. $crumb = '<a href="http://'.$url.'">'.$title.'</a> > ';
  22. echo $crumb;
  23. $i++;
  24. }
  25. }
  26. }

Report this snippet  

You need to login to post a comment.