function custom_breadcrumbs_views_views_pre_render in Custom Breadcrumbs 6.2
Implements hook_views_pre_render().
File
- custom_breadcrumbs_views/
custom_breadcrumbs_views.module, line 74
Code
function custom_breadcrumbs_views_views_pre_render(&$view) {
// Don't really do anything with the view. This is just a pretense to insert a breadcrumb.
global $language;
$languages = array(
'language' => $language->language,
'all' => '',
);
$curpath = drupal_get_normal_path($_GET['q']);
// Check to see if the view path matches the current path.
foreach ($view->display as $id => $display) {
// Identify allowed displays for breadcrumb replacement.
if (!_custom_breadcrumbs_allowed_display($display)) {
continue;
}
$viewpath = _custom_breadcrumbs_construct_view_path($display);
if (_custom_breadcrumbs_match_path($curpath, $viewpath)) {
$loadpath = $display->display_options['path'];
$breadcrumbs = custom_breadcrumbs_load_breadcrumbs('custom_breadcrumbs_views', NULL, array(
'views_path' => $loadpath,
), $languages);
if (!empty($breadcrumbs)) {
if ($breadcrumb = custom_breadcrumbs_select_breadcrumb($breadcrumbs, array(
'view' => $view,
))) {
// Select breadcrumb for the matching display with the greatest number of explicit arguments.
$num = substr_count($breadcrumb->views_path, '%');
if (!isset($max) || isset($max) && $num > $max) {
$max = $num;
$candidate = $breadcrumb;
$max_id = $id;
}
}
}
}
}
if (isset($candidate)) {
$objs = _custom_breadcrumbs_views_token_types($view->display[$max_id]);
$objs['view'] = $view;
if (!isset($objs['node']) && isset($view->result[0]->nid)) {
$node = node_load(array(
'nid' => $view->result[0]->nid,
));
$objs['node'] = $node;
}
custom_breadcrumbs_set_breadcrumb($candidate, $objs);
return;
}
if (variable_get('custom_breadcrumbs_set_menu_breadcrumb', FALSE) && !custom_breadcrumbs_exclude_path()) {
// If a views breadcrumb has not been defined for this view, then use the default menu structure.
custom_breadcrumbs_set_menu_breadcrumb();
}
}