function custom_breadcrumbs_panels_ctools_render_alter in Custom Breadcrumbs 6.2
Same name and namespace in other branches
- 7.2 custom_breadcrumbs_panels/custom_breadcrumbs_panels.module \custom_breadcrumbs_panels_ctools_render_alter()
Implements hook_ctools_render_alter().
File
- custom_breadcrumbs_panels/
custom_breadcrumbs_panels.module, line 104
Code
function custom_breadcrumbs_panels_ctools_render_alter($info, $page, $args, $contexts, $task, $subtask, $handler) {
// Don't really do anything with the panel. This is just a pretense to insert a breadcrumb.
static $module_weights = array();
if ($page) {
global $language;
$languages = array(
'language' => $language->language,
'all' => '',
);
// Check to see if the panel ID matches any custom_breadcrumb panel_id.
// First, try to find a match on panels variant id.
$id = $handler->name;
$breadcrumbs = custom_breadcrumbs_load_breadcrumbs('custom_breadcrumbs_panels', NULL, array(
'panel_id' => $id,
), $languages);
// If nothing matched, try matching on panels page id.
if (empty($breadcrumbs)) {
$id = $handler->task;
$breadcrumbs = custom_breadcrumbs_load_breadcrumbs('custom_breadcrumbs_panels', NULL, array(
'panel_id' => $id,
), $languages);
}
if (!empty($breadcrumbs)) {
if ($breadcrumb = custom_breadcrumbs_select_breadcrumb($breadcrumbs, array(
'panel' => $info,
))) {
$objs = array(
'panel' => $info,
);
foreach ($contexts as $context) {
if ($context->type == 'node') {
$objs['node'] = $context->data;
}
}
custom_breadcrumbs_set_breadcrumb($breadcrumb, $objs);
// Stop after a match has been found.
return;
}
}
}
// Is this a taxonomy term template?
if (isset($task['admin path']) && $task['admin path'] == "taxonomy/term/%term" && module_exists('custom_breadcrumbs_taxonomy') && variable_get('custom_breadcrumbs_taxonomy_panels', FALSE)) {
module_load_include('inc', 'custom_breadcrumbs_taxonomy');
foreach ($contexts as $context) {
if (isset($context->data->tid)) {
$terms = array(
$context->data->tid => $context->data,
);
_custom_breadcrumbs_taxonomy_set_breadcrumb($context->data->tid, $context->data->vid, TRUE, array(), $terms);
return;
}
}
}
// Is this a node template?
if (isset($task['admin path']) && $task['admin path'] == "node/%node") {
$context = array_pop($contexts);
if ($context->type == 'node' && isset($context->data)) {
$node = $context->data;
// Call hook_nodeapi for each Custom Breadcrumbs submodule in order of the module's weight.
if (empty($module_weights)) {
$modules = module_implements('cb_breadcrumb_info');
$module_weights = _custom_breadcrumbs_get_module_weight($modules);
unset($module_weights['custom_breadcrumbs_panels']);
}
foreach ($module_weights as $module_name => $weight) {
$func = $module_name . '_nodeapi';
if (function_exists($func)) {
$func($node, 'alter', array(), array(
1,
));
}
}
return;
}
}
if (variable_get('custom_breadcrumbs_set_menu_breadcrumb', FALSE)) {
// If a panels breadcrumb has not been defined for this panel, then use the default menu structure.
custom_breadcrumbs_set_menu_breadcrumb();
}
}