function _custom_breadcrumbs_paths_set_breadcrumb in Custom Breadcrumbs 6.2
Same name and namespace in other branches
- 7.2 custom_breadcrumbs_paths/custom_breadcrumbs_paths.module \_custom_breadcrumbs_paths_set_breadcrumb()
Checks for a custom breadcrumb at the current path and sets it if one is found.
Parameters
$objs: An array of objects to be used in token replacement. Array keys indicate type of object.
$priority: An integer indicating whether this attempt should override previous attempts. The lowest priority is 1. Higher values are given priority over lower values.
3 calls to _custom_breadcrumbs_paths_set_breadcrumb()
- custom_breadcrumbs_paths_nodeapi in custom_breadcrumbs_paths/
custom_breadcrumbs_paths.module - Implements hook_nodeapi().
- custom_breadcrumbs_paths_preprocess_page in custom_breadcrumbs_paths/
custom_breadcrumbs_paths.module - Implements hook_preprocess_page().
- custom_breadcrumbs_paths_views_pre_render in custom_breadcrumbs_paths/
custom_breadcrumbs_paths.module - Implements hook_views_pre_render().
File
- custom_breadcrumbs_paths/
custom_breadcrumbs_paths.module, line 122
Code
function _custom_breadcrumbs_paths_set_breadcrumb($objs = array(), $priority = 1) {
static $success;
// Allow a higher priority request to take precedence.
if (!isset($success) || $priority > $success) {
$matchpath = variable_get('custom_breadcrumbs_paths_allow_wildcards', FALSE);
$breadcrumbs = _custom_breadcrumbs_paths_get_breadcrumbs($matchpath);
if (!empty($breadcrumbs)) {
foreach ($breadcrumbs as $id => $breadcrumb) {
if (!$matchpath || _custom_breadcrumbs_paths_page_match($breadcrumb)) {
if (custom_breadcrumbs_is_visible($breadcrumb, $objs)) {
if ($matchpath) {
// Assume a longer path match is a better fit than a prior shorter match.
if (($pos = strrpos($breadcrumb->specific_path, '*')) !== FALSE) {
if (!isset($max) || isset($max) && $pos > $max) {
$max = $pos;
$max_id = $id;
}
}
else {
// No wildcards in this breadcrumb, so its a direct match.
$max_id = $id;
// Don't check any others once a visible breadcrumb is found.
break;
}
}
else {
// Wildcards are not allowed, so this must be a direct match.
$max_id = $id;
// Don't check any others once a visible breadcrumb is found.
break;
}
}
}
}
if (isset($max_id)) {
custom_breadcrumbs_set_breadcrumb($breadcrumbs[$max_id], $objs);
$success = $priority;
return TRUE;
}
}
}
return FALSE;
}