In my template preprocess html
and page
hooks, I test the current page of being a certain kind of node, set by the menu structure. Given such a menu:
main menu
- link 1
- link 2 (specials)
- > link 2.1
- > link 2.2
- link 3
Every node which menu's link has the menu parent link 2
gets a treatment. On those nodes, I also want to only show all links inside link 2 menu, so start the main menu from that, so basically the main menu would then consist of link 2.1
and link 2.2
. How would you do that?
function mytheme_preprocess_html(&$vars) {
$special = is_special_page();
if ($special) {
// alter menu
}
}
function mytheme_preprocess_page(&$vars) {
$special = is_special_page();
if ($special) {
// alter menu
}
}
function is_special_page($node) {
$breadcrumbs = drupal_get_breadcrumb();
$businessMatch = preg_grep("/(specials?)/i", $breadcrumbs);
return (count($businessMatch) > 0);
}