I'm writing a very simple module to alter the active trail on specific pages. Observe.

function alter_breadcrumbs_menu_breadcrumb_alter(&$active_trail, $item) {
  if (substr($item['href'], 0, 4) == 'user') {
    $num_crumbs = count($active_trail);
    $people = array(
      'href' => 'people',
      'title' => t('People'),
      'localized_options' => array(),
    $active_trail[] = $people;

The profile page by default has the breadcrumb 'Home'. I have a directory page that has a list of users with links to their profile pages. This page is located under /people. So, on the user page, I want the breadcrumbs to look like 'Home > People > John Smith'.

I expect the code above to produce 'Home > People', but it doesn't. Instead, it produces 'Home > jsmith > People'. It puts in jsmith instead of John Smith because John Smith is derived from custom first and last name fields, but the crumbs currently just take the user's username by default, so ignore that fact for now. What it comes down to is I don't understand why it's pushing on the username crumb and the People crumb, rather than just the People crumb. Any insight would be helpful.


2 Answers 2


It looks like your adding $people to the end of the array, you have to insert it in second place, using http://php.net/manual/en/function.array-pop.php you can do something like this (untested):

$name = array_pop($active_trail);
$active_trail[] = $people;
$active_trail[] = $name;
  • I tried that originally, but the results ended up as 'Home > People'. I'm pretty sure it's because the Drupal core follows up this function call by stripping out the last link in the trail if the link represents the current page, which it would. I solved it by duplicating the last line in your example. Now I just need to figure out how to access the first and last name fields of the User object and overwrite the title field of the last active trail item. Commented Aug 1, 2011 at 19:20
$breadcrumb = array();
$breadcrumb[] = l($breadCrumbTitle, $linkPath);

Your Answer

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

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