7

I have a theme which sets breadcrumbs like this:

function mytheme_process_node(&$variables) {
    (....)
    drupal_set_breadcrumb($my_breadcrumbs_array);
}

This gets overwritten later by something else. I need a specific taxonomy value of the displayed node to set the breadcrumb, that's why I am using this hook. How to do it effectively? Perhaps there is a hook which is performed later and still has access to the node object?

  • "a specific taxonomy value" - that is, a specific taxonomy term reference field? – donquixote Oct 7 '13 at 15:14
7

I normally stick that logic in hook_preprocess_page(), it runs late enough in the page build to not be overwritten by anything else.

You can still get access to the node object by using the menu_get_object() function:

function MYTHEME_preprocess_page(&$vars) {
  if ($node = menu_get_object()) {
    // We're on a node page...
    drupal_set_breadcrumb($my_breadcrumbs_array);
  }
}
| improve this answer | |
3

There is also hook_menu_breadcrumb_alter()

Besides, you can use one of the plenty of breadcrumb-customizing modules and might get what you want without custom code.

| improve this answer | |
  • It is tempting to use this hook but you may end up with a correct breadcrumb and a wrong menu active trail. – Wtower Jan 22 '15 at 18:14

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.