function custom_breadcrumbs_nodeapi in Custom Breadcrumbs 5
Same name and namespace in other branches
- 6.2 custom_breadcrumbs.module \custom_breadcrumbs_nodeapi()
- 6 custom_breadcrumbs.module \custom_breadcrumbs_nodeapi()
File
- ./
custom_breadcrumbs.module, line 45
Code
function custom_breadcrumbs_nodeapi($node, $op, $teaser, $page) {
if ($op == 'view' && !$teaser && $page) {
if ($breadcrumb = _custom_breadcrumbs_load_for_type($node)) {
$titles = preg_split("/[\n]+/", $breadcrumb->titles);
$paths = preg_split("/[\n]+/", $breadcrumb->paths);
$titles = module_exists('token') ? token_replace($titles, 'node', $node) : $titles;
$paths = module_exists('token') ? token_replace($paths, 'node', $node) : $paths;
$trail = array(
l(t('Home'), ''),
);
$location = array();
for ($i = 0; $i < count($titles); $i++) {
// Skip empty titles
if ($title = trim($titles[$i])) {
$title = $title == '<none>' ? ' ' : decode_entities($title);
// Output plaintext instead of a link if there is a title without a path.
$path = trim($paths[$i]);
if (strlen($path) > 0 && $path != '<none>') {
$parsed = parse_url($path);
$trail[] = l($title, $parsed['path'], array(), $parsed['query']);
}
else {
$trail[] = check_plain($title);
}
$location[] = array(
'title' => $title,
'path' => drupal_get_normal_path($path),
);
}
}
drupal_set_breadcrumb($trail);
menu_set_location($location);
}
}
}