function _custom_breadcrumbs_get_breadcrumb in Custom Breadcrumbs 6.2
Same name and namespace in other branches
- 7.2 custom_breadcrumbs.module \_custom_breadcrumbs_get_breadcrumb()
Gets the custom breadcrumb.
This function is used to retrieve the breadcrumb trail before actually setting it.
Parameters
$breadcrumb: The breadcrumb object.
$objs: An array of object (if available) for building token substituions.
$locations: Locations array to be able to set active menu trail - passed by reference.
Return value
array of html crumbs
See also
custom_breadcrumbs_get_breadcrumb().
1 call to _custom_breadcrumbs_get_breadcrumb()
- custom_breadcrumbs_set_breadcrumb in ./
custom_breadcrumbs.module - Sets the custom breadcrumb.
File
- ./
custom_breadcrumbs.module, line 334 - Provide custom breadcrumbs for node-type pages and base functionality for submodules to add custom breadcrumbs for other types of pages.
Code
function _custom_breadcrumbs_get_breadcrumb($breadcrumb, $objs, &$locations) {
// Assure locations is an array.
if (!is_array($locations)) {
$locations = array();
}
elseif (isset($locations['title']) || isset($locations['href'])) {
$locations = array(
$locations,
);
}
$trail = custom_breadcrumbs_home_crumb();
if (!empty($trail)) {
$title = variable_get('custom_breadcrumb_home', t('Home'));
$locations[] = array(
'title' => variable_get('custom_breadcrumb_home', t('Home')),
'href' => '<front>',
'localized_options' => array(),
);
}
if (variable_get('custom_breadcrumbs_use_php_in_titles', FALSE)) {
$titles = extract_php($breadcrumb->titles, $objs);
// Titles and paths arrays can also be provided as elements of an associative array.
if (isset($titles['titles']) && is_array($titles['titles']) && isset($titles['paths']) && is_array($titles['paths'])) {
$paths = $titles['paths'];
$titles = $titles['titles'];
}
else {
$paths = extract_php($breadcrumb->paths, $objs);
}
}
if (!isset($titles) || is_null($titles)) {
$titles = preg_split("/[\n]+/", $breadcrumb->titles);
}
if (!isset($paths) || is_null($paths)) {
$paths = preg_split("/[\n]+/", $breadcrumb->paths);
}
// Token replacement for titles and paths
if (module_exists('token')) {
// Do token replacement.
$types = custom_breadcrumbs_token_types($objs);
foreach ($titles as $index => $value) {
$titles[$index] = token_replace_multiple($value, $types);
}
foreach ($paths as $index => $value) {
$paths[$index] = token_replace_multiple($value, $types);
}
}
// Optionally append the page title
if (variable_get('custom_breadcrumbs_append_page_title', FALSE) && !drupal_is_front_page()) {
$titles[] = drupal_get_title();
if (variable_get('custom_breadcrumbs_append_page_title_no_link', FALSE)) {
$paths[] = '<none>';
}
else {
$paths[] = $_GET['q'];
}
}
$items = _custom_breadcrumbs_get_trail_items($breadcrumb, $titles, $paths);
// Use the returned items to set the trail.
foreach ($items as $item) {
if ($item['crumb']) {
$trail[] = $item['crumb'];
}
if (variable_get('custom_breadcrumbs_force_active_trail', FALSE)) {
$locations[] = array(
'title' => $item['title'],
'href' => drupal_get_normal_path(trim($item['href'])),
);
}
}
return $trail;
}