3

How can I set the breadcrumbs for a node? I have a node which is in the menu and also the head menu with the id 2 which contains the imprint.

If I open my page http://my.page.tld/imprint (I'm using the SEO stuff) I can see my text with the correct title but with no useful breadcrumbs. It's Home instead of Home » Imprint.

How can I fix that?

4 Answers 4

7

You can use Menu Breadcrumb. It allows you to Append the page title to the breadcrumb (either as a clickable url or not) . Or you can edit your theme's page.tpl.php - simply add $title after the $breadcrumb variable.

There are also a ton of other breadcrumb modules if you want to get fancy:

  1. Crumbs
  2. Custom Breadcrumbs
  3. Hansel

See an older comparison chart.

2
  • I tried already Custom Breadcrumbs without success. Menu Breadcrumb does its job for the imprint. But not for a taxonomy entry in the menu. I'm keep looking how to fix that.
    – rekire
    Jan 20, 2012 at 0:43
  • 1
    Custom Breadcrumbs is genius. Use [node:title] as title and [node:url:relative] as your path.
    – jumper
    Jan 20, 2012 at 1:23
4

A simple custom solution would be to add a function like this in your theme's template.php file:

function MYTHEME_preprocess_node(&$variables) {
  //Retrieve current breadcrumb
  $breadcrumbs = drupal_get_breadcrumb();
  //Add the title without link
  $breadcrumbs[] = $variables['node']->title;
  //OR add the title with a link
  $breadcrumbs[] = l($variables['node']->title, 'node/'.$variables['node']->nid);

  //Set the new breadcrumb
  drupal_set_breadcrumb($breadcrumbs);
}
3
  • Code solutions are great too. But the module seems to be easier in this case.
    – rekire
    Jan 20, 2012 at 0:46
  • Of course, it was to give you a very small alternative as a site can be rapidly overloaded with modules ;)
    – tostinni
    Jan 20, 2012 at 15:27
  • I used your solution for a second problem. I could add so the breadcrumps for the taxonomies.
    – rekire
    Jan 20, 2012 at 16:13
3

Breadcrumbs do not include the name of the current page. The thought behind this is that you are on the page and do not need a link to get there. Breadcrumbs are a link menu that is always one step back, so you can back up quickly.

1
  • Thank you I see now the reason. I think that Google analyses the breadcrumps so it would make sense for the imprint in my opinion. How can I achive that?
    – rekire
    Jan 20, 2012 at 0:16
0

Put this code in template.php (and change MYTHEME to your theme name)

function MYTHEME_breadcrumb($variables) {
  $variables['breadcrumb'][] = drupal_get_title();
  return theme_breadcrumb($variables);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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