function menu_views_menu_breadcrumb_alter in Menu Views 7.2
Same name and namespace in other branches
- 8.3 menu_views.module \menu_views_menu_breadcrumb_alter()
Implements hook_menu_breadcrumb_alter().
File
- ./
menu_views.module, line 136 - Module to allow Views to be attached as menu items.
Code
function menu_views_menu_breadcrumb_alter(&$active_trail, $item) {
foreach ($active_trail as $key => $parent) {
if (isset($parent['link_path']) && $parent['link_path'] == '<view>') {
$menu_view = _menu_views_get_item($parent);
_menu_views_tokenize($menu_view);
// Remove this breadcrumb if the menu item view wants it hidden.
if (!(bool) $menu_view['view']['settings']['breadcrumb']) {
unset($active_trail[$key]);
}
else {
// Use overridden title if provided.
$title = filter_xss_admin($menu_view['view']['settings']['breadcrumb_title']);
// Use title provided by view next.
if (empty($title)) {
$view = views_get_view($menu_view['view']['name']);
if ($view && $view
->access($menu_view['view']['display']) && $view
->set_display($menu_view['view']['display'])) {
$title = filter_xss_admin($view
->get_title());
$view
->destroy();
}
}
// If title is still empty, just remove it from the breadcrumb.
if (empty($title)) {
unset($active_trail[$key]);
}
else {
$active_trail[$key]['title'] = $title;
$active_trail[$key]['href'] = $menu_view['view']['settings']['breadcrumb_path'];
}
}
}
}
}