function menu_position_token_menu_link_load in Menu Position 7
Return a menu link for the given node.
It uses the first menu position rule activated for that node.
1 call to menu_position_token_menu_link_load()
- menu_position_tokens_alter in ./
menu_position.module - Implements hook_tokens_alter().
File
- ./
menu_position.module, line 652 - Provides dynamic menu links based on configurable rules.
Code
function menu_position_token_menu_link_load($node) {
$cache =& drupal_static(__FUNCTION__);
if (!isset($cache)) {
$cache = array();
}
if (!array_key_exists($node->nid, $cache)) {
// Check for a menu position menu link.
$context = array(
'path' => sprintf('node/%d', $node->nid),
'entity_type' => 'node',
'bundle_name' => $node->type,
'node' => $node,
);
if ($rules = menu_position_get_activated_rules($context)) {
$rule = array_shift($rules);
$link = token_menu_link_load($rule->mlid);
}
else {
$link = NULL;
}
$cache[$node->nid] = $link;
}
return $cache[$node->nid];
}