I am using custom breadcrumbs and almost all is working well but a few issues. One problem stated in another question, this problem is that on the landing page of my views I am getting home >> Homme >> Homme. I need to remove the duplicate. I see there is a form in the configuration for breadcrumb visibility. Is this where I solve this problem. I see no other way to do this. Does anyone know or have the code I need?

3 Answers 3


I think you could use theme_breadcrumb($variables) in your template.php to remove duplicates.

Code could be something like this:

themeName_breadcrumb($variables) {
  $breadcrumbs = array_unique($variables['breadcrumb']);
  • Ok what goes in the [...] areas. I am not very good with php and really don't understand most of it. Jan 26, 2012 at 21:12
  • This is default function implementation, you can look for it in inclides/theme.inc. It is around 1660 line for Drupal 7.10
    – nextanz
    Jan 26, 2012 at 21:21

For some reason I was getting duplicates in my breadcrumb. But they weren't quite duplicates, one would have an anchor element with a title, the other wouldn't, thus I had to check only the html within the anchor element, not the entire row of the array.

I didn't have time to totally debug it. Here's what I did:

function [yourtheme]_breadcrumb($variables) {
  // Convenience variable:
  $breadcrumb = $variables['breadcrumb'];

  //For some reason there are duplicate entries in the breadcrumb, this will remove them
  $flags = array(); 
  foreach($breadcrumb as $key => $bc){
    $startPos = strpos($bc,'>');
    $flag = substr($bc,$startPos);
    if (in_array($flag,$flags)){
    $flags[] = $flag;

  //That's the only relevant code, the rest of this is for another purpose

  // If we have any breadcrumbs:
  if (!empty($breadcrumb)) {
    $breadcrumb[] = drupal_get_title();

    // Convert 'em to a string:
    $breadcrumbs = implode(' <span class="divider">/</span> ', $breadcrumb);
    // Build a heading--here at least, we're following the D7 convention of
    // accompanying menus with invisible headings to aid in text-only navigation:
    $heading = t('You are here');
    // Pattern for output:
    $output_pattern = '<h2 class="element-invisible">%s</h2><ul class="breadcrumb">%s</ul>';
    // Return the markup:
    return sprintf($output_pattern, $heading, $breadcrumbs);

Why do you use theme function instead of the preprocess?

function THEME_preprocess_breadcrumb(&$variables) {
  $all = array();
  foreach ($variables['breadcrumb'] as $key=>$item) {
    if (preg_match('|href="(.*)"|Ui', $item, $matches)) {
      if (isset($all[$matches[1]])) {
      } else {
        $all[$matches[1]] = 1;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.