function rb_misc_action_set_active_menu_item in Rules Bonus Pack 7
Same name and namespace in other branches
- 6 rb_misc.module \rb_misc_action_set_active_menu_item()
The 'rb_misc_action_set_title' action.
File
- ./
rb_misc.rules.inc, line 635 - Miscellaneous conditions and actions for Rules.
Code
function rb_misc_action_set_active_menu_item($mlid) {
// 90 percent of the code below is shamelessly stolen from the menu_position
// module, by JohnAlbin (http://drupal.org/user/32095). Cred to him!
// Retrieve menu item specified in the settings.
$menu_item = menu_link_load($mlid);
// Clone the original router item, but insert our menu_position path.
$original_router_item = menu_get_item();
$router_item = $original_router_item;
$router_item['href'] = $menu_item['link_path'];
$router_item['menu_name'] = $menu_item['menu_name'];
// Even if we are denied access to the page, we still want to show the
// navigational paths to the page.
$router_item['access'] = TRUE;
// Temporarily override the original router item.
menu_set_item(NULL, $router_item);
// The magic goes here. Cred to JohnAlbin.
menu_position_precache_tree($router_item, $original_router_item, $menu_item['menu_name']);
// Also store the new, faked active mlid tree in drupal_static, for use by
// other modules (such as Views menu support).
$faked_tree =& drupal_static('rb_misc_mlid_trail');
foreach (range(1, 9) as $index) {
if ($menu_item['p' . $index]) {
$faked_tree[] = $menu_item['p' . $index];
}
}
// Restore the original router item.
menu_set_item(NULL, $original_router_item);
}