function menu_position_page_delivery_callback_alter in Menu Position 7
Same name and namespace in other branches
- 7.2 menu_position.module \menu_position_page_delivery_callback_alter()
Implements hook_page_delivery_callback_alter().
This is the only hook that occurs after the page callback, but before hook_page_build (when blocks are added). We're using this hook for its timing, not its data.
1 call to menu_position_page_delivery_callback_alter()
- menu_position_panels_pre_render in ./
menu_position.module - Implements hook_panels_pane_content_alter().
File
- ./
menu_position.module, line 39 - Provides dynamic menu links based on configurable rules.
Code
function menu_position_page_delivery_callback_alter() {
// Don't evaluate the rules twice.
$evaluated =& drupal_static(__FUNCTION__, FALSE);
if ($evaluated) {
return;
}
$evaluated = TRUE;
// Build a small context.
$context = array(
'path' => $_GET['q'],
'entity_type' => NULL,
'bundle_name' => NULL,
);
// Determine what kind of entity page this is.
list($arg0, $arg1, $arg2) = explode('/', $context['path'] . '//');
if ($arg0 == 'node' && is_numeric($arg1)) {
$context['node'] = node_load($arg1);
// Don't evaluate the rules on a 404 page.
if (!$context['node']) {
return;
}
$context['entity_type'] = 'node';
$context['bundle_name'] = $context['node']->type;
}
elseif ($arg0 == 'user' && is_numeric($arg1)) {
$context['user'] = user_load($arg1);
// Don't evaluate the rules on a 404 page.
if (!$context['user']) {
return;
}
$context['entity_type'] = 'user';
$context['bundle_name'] = 'user';
}
elseif ($arg0 == 'taxonomy' && $arg1 == 'term' && is_numeric($arg2)) {
$context['taxonomy_term'] = taxonomy_term_load($arg2);
// Don't evaluate the rules on a 404 page.
if (!$context['taxonomy_term']) {
return;
}
$context['entity_type'] = 'taxonomy_term';
$context['bundle_name'] = $context['taxonomy_term']->vocabulary_machine_name;
}
menu_position_evaluate_rules($context);
}