I need help. I've got this in my template.php. It change the Home text in drupal breadcrumb to my new custom one:

function MYTHEME_menu_breadcrumb_alter(&$breadcrumb) {
  // If there's a breadcrumb defined
  if (!empty($breadcrumb)) {
    // We'll change the root crumb values
    $breadcrumb[0]['title'] = t('My new Home text');
  }
}

Everything works fine but I use custom breadcrumbs module as well and thats the problem. My code posted above doesn't work on pages which are modified/affected with that module (for example breadcrumb at the views page is ok, but if I open node page with custom breadcrumb it shows default drupal 'Home' link).

This code:

function custom_breadcrumbs_node_view($node, $build_mode) {
  if ($build_mode == 'full' && ($breadcrumb = _custom_breadcrumbs_load_for_type($node))) {
    $titles = preg_split("/[\n]+/", $breadcrumb->titles);
    $paths = preg_split("/[\n]+/", $breadcrumb->paths);

    $trail = array(l(t('Home'), '<front>'));
    for ($i = 0; $i < count($titles); $i++) {
      $data = array('node' => $node);
      $title = token_replace(trim($titles[$i]), $data, array('clear'=>TRUE));
      if (($title != '') && ($title != '<none>')) {
        $path = token_replace(trim($paths[$i]), $data, array('clear'=>TRUE));
        // Create breadcrumb only if there is a title.
        $trail[] = _custom_breadcrumbs_create_crumb($title, $path);
      }
    }
    drupal_set_breadcrumb($trail);
  }
}

is in the custom_breadcrumbs.module file. I dont want to change the 'Home' text here. What is the correct way how can I override this function in my template.php file? Could you help me please?

Comments

zpages’s picture

nobody?

evgeny.chernyavskiy’s picture

drupal_get_breadcrumb() calls drupal_alter( 'menu_breadcrumb' ) at some point, which allows you to override the breadcrumb via your own module.
thus, you'll need to implement hook_menu_breadcrumb_alter() in your module.
looking at the source of drupal_get_breadcrumb() will also help to get the idea.

LonitaD’s picture

Custom Breadcrumbs never calls drupal_get_breadcrumb() so hook_menu_breadcrumb_alter() doesn't work. I solved it by commenting out the $trail = array(l(t('Home'), '')); line (line 99). I don't like to hack modules, but in this case it seemed unavoidable. Just make sure the first breadcrumb in your custom breadcrumb settings for the node type is 'My new Home text' and it should work. If there is a better solution, I would like to know.

pwiniacki’s picture

It would be nice if default drupal breadcrumb have it HOME start name configurable (with language addition support off course).

Drupal beginer