Breadcrumb function


/ Published in: PHP
Save to your folder(s)

Function to print breadcrumb links


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.