How to edit breadcrumb in drupal 7?

by peifa   Last Updated May 13, 2015 12:40 PM

How to edit breadcrumb info without install any drupal module?
Example: blog
Home >> blog >> admin's blog

I want to remove admin's blog

Many Thank.

Tags : 7 breadcrumbs


Answers 3


Check the menu_get_active_trail() and menu_set_active_trail() functions. They should be of use for what you want (retreiving and changing your breadcrumb).

Try the following in your template.php in your theme :

/**
 * Implementing theme_preprocess_html
 */
function YOURTHEME_preprocess_html(&$vars) {
    $crumbs = menu_get_active_trail();
    $count = count($crumbs);
    // dpm($crumbs);
    unset($crumbs[$count - 1]);
    menu_set_active_trail($crumbs);
}

See how it goes.

rtome
rtome
May 13, 2015 10:35 AM

You can use this code in page.tpl.php replace with breadcrumb code.

$breadcrumb_array = drupal_get_breadcrumb();

print $breadcrumb_array[0]

drupal_get_breadcrumb() gives the array.

You can use array as you want.

Please let me know code worked for you

Ankit Aneja
Ankit Aneja
May 13, 2015 11:56 AM

you can override breadcrumbs theme in your template.php file

$variables : An array containing the breadcrumb links

/**
 * Implementing theme_breadcrumb
 */

function theme_breadcrumb($variables) {
  $breadcrumb = $variables ['breadcrumb'];

  if (!empty($breadcrumb)) {
    // edit $breadcrumbs here
    $output = '<div class="breadcrumb">' . implode(' ยป ', $breadcrumb) . '</div>';
    return $output;
  }
}

https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_breadcrumb/7

Abdulla Abu Zakham
Abdulla Abu Zakham
May 13, 2015 13:43 PM

Related Questions


Remove href from last breadcrumb

Updated August 06, 2015 17:03 PM

Drupal 7 easy breadcrumb module hides breadcrumbs

Updated April 20, 2015 21:03 PM

How do you implement a breadcrumb in Drupal 8?

Updated March 06, 2016 01:03 AM

How to create static breadcrumb

Updated February 19, 2016 01:03 AM

Breadcrumbs customization without use of any module

Updated March 05, 2016 01:03 AM