I have a Drupal 6.26 site with a custom menu like so:

-Category 1
-Category 2

All Category pages are genrated by a view (e.g. sitename.com/intranet/category)

All pages that are children of each category are nodes.

My primary problem is, when a category page is selected, the menu it's associated with doesn't expand. The site owner doesn't want the menus expanded by default.

A secondary problem is the menu won't expand when one of the child pages is selected unless it has the path /intranet/category/*, which is not always desired.

Hopefully a bit of code can solve this issue.


Five lines of code placed in a views template file solved the issue:

    $path = drupal_get_path_alias(check_plain($_GET['q']));
    $menu_item = menu_get_item($path);
    $menu_item['href'] = $path;
    if($path && $menu_item) {
      menu_set_item(NULL, $menu_item);
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.