function menu_get_active_breadcrumb

Gets the breadcrumb for the current page, as determined by the active trail.

See also

menu_set_active_trail()

Related topics

2 calls to menu_get_active_breadcrumb()
drupal_get_breadcrumb in includes/common.inc
Gets the breadcrumb trail for the current page.
menu_edit_item in modules/menu/menu.admin.inc
Menu callback; Build the menu link editing form.

File

includes/menu.inc, line 2592

Code

function menu_get_active_breadcrumb() {
    $breadcrumb = array();
    // No breadcrumb for the front page.
    if (drupal_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.
        drupal_alter('menu_breadcrumb', $active_trail, $item);
        // Don't show a link to the current page in the breadcrumb trail.
        $end = end($active_trail);
        if (is_array($end) && $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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.