1 menu.inc | menu_get_active_breadcrumb() |
Gets the breadcrumb for the current page, as determined by the active trail.
See also
Related topics
File
- core/
includes/ menu.inc, line 2737 - API for the Backdrop menu system.
Code
function menu_get_active_breadcrumb() {
$breadcrumb = array();
// No breadcrumb for the home page.
if (backdrop_is_front_page()) {
return $breadcrumb;
}
$item = menu_get_item();
if (!empty($item['access'])) {
$active_trail = menu_get_active_trail();
// Allow modules to alter the breadcrumb, if possible, as that is much
// faster than rebuilding an entirely new active trail.
backdrop_alter('menu_breadcrumb', $active_trail, $item);
// Don't show a link to the current page in the breadcrumb trail.
$end = end($active_trail);
if ($item['href'] == $end['href']) {
array_pop($active_trail);
}
// Remove the tab root (parent) if the current path links to its parent.
// Normally, the tab root link is included in the breadcrumb, as soon as we
// are on a local task or any other child link. However, if we are on a
// default local task (e.g., node/%/view), then we do not want the tab root
// link (e.g., node/%) to appear, as it would be identical to the current
// page. Since this behavior also needs to work recursively (i.e., on
// default local tasks of default local tasks), and since the last non-task
// link in the trail is used as page title (see menu_get_active_title()),
// this condition cannot be cleanly integrated into menu_get_active_trail().
// menu_get_active_trail() already skips all links that link to their parent
// (commonly MENU_DEFAULT_LOCAL_TASK). In order to also hide the parent link
// itself, we always remove the last link in the trail, if the current
// router item links to its parent.
if (($item['type'] & MENU_LINKS_TO_PARENT) == MENU_LINKS_TO_PARENT) {
array_pop($active_trail);
}
foreach ($active_trail as $parent) {
$breadcrumb[] = l($parent['title'], $parent['href'], $parent['localized_options']);
}
}
return $breadcrumb;
}