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?

1
  • "a specific taxonomy value" - that is, a specific taxonomy term reference field? Commented Oct 7, 2013 at 15:14

2 Answers 2

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); } } 
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.

1
  • It is tempting to use this hook but you may end up with a correct breadcrumb and a wrong menu active trail. Commented Jan 22, 2015 at 18:14

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.