Drupal – Theme the Breadcrumb

If you want to override the default breadcrumb HTML output, you can add the following theme_breadcrumb() function in the template.php under your current theme folder.

The following piece of code is an example which add a class for the current breadcrumb.

<?php
/**
* Allow themable breadcrumbs
*/
function theme_breadcrumb($breadcrumb) {
  if (!empty($breadcrumb)) {
    $lastitem = sizeof($breadcrumb);
    $crumbs = '<div class="breadcrumbs">';
    $a=1;
    foreach($breadcrumb as $value) {
        if ($a!=$lastitem){
         $crumbs .= '<p>'.$value.'</p>';
         $a++;
        }
        else {
            $crumbs .= '<p class="breadcrumbcurrent">'.$value.'</p>';
        }
    }
    $crumbs .= '</div>';
  }
  return $crumbs;
}
?>

 

Reference:

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.