Skip to main content
3 of 3
Clarification.
mpdonadio
  • 38.1k
  • 8
  • 89
  • 142

Proper use of hook_menu_breadcrumb_alter()

I have a situation where I need to mess with a breadcrumb on a page and insert some items in the middle. In my instance drupal_set_breadcrumb() can't be used, so I need to implement a hook_menu_breadcrumb_alter(). I am a little confused about proper usage with this, though, and am not terribly familiar with the guts of how the menu module works.

Is there a proper method for building elements that go into the $active_trail array, eg

$foo = array(
  'title' => $node->title,
  'href' => 'node/' . $node->nid,
  'link_path' => '',
  'localized_options' => array(),
  'type' => 0,
);

title and href are easy enough, but I don't quite get how the other play into this particular context. It is easy enough to figure this out from what is there, but I would like to do "the right thing".

Is there a proper method (or best practice) for testing whether $item is a node and to load it? Again, I can dpm($item), poke around, and get what I need.

I have what I need working, but it is messy and would like to fix it for the long term.

mpdonadio
  • 38.1k
  • 8
  • 89
  • 142