Running on Drupal 6.x

I was doing some mucking around in code with the menu functions and now all of a sudden the system seems to *always* think the active menu name is "navigation".

Shouldn't clicking on a primary link set the active menu name to "primary-links" ? for some reason it continously returns navigation now and it's killing a module that I had developed.

I can fix this issue by manually adding a set_active_menu_name('primary-links'); call into my module but this was never required before when it was working and I assume the system was correctly defining the active menu as primary links before I started meddling with some menu api calls. It seems broken now since it continually returns navigation as the active menu name even when I'm clicking through my primary-links.

Any help is greatly appreciated!

Comments

skalfyfan’s picture

Found the solution!

Ignore. Thanks anyhow!

Anonymous’s picture

Can you please tell me how you fixed this since I'm in the same struggle as you?

Thanks

/ronnil

galaober’s picture

Yes, i have this problem :(
My solution - little hack

--- menu.inc.orig	2008-04-10 00:11:44.000000000 +0300
+++ menu.inc	2008-06-03 16:36:02.000000000 +0300
@@ -1443,7 +1443,11 @@
     $active = $menu_name;
   }
   elseif (!isset($active)) {
-    $active = 'navigation';
+    // Try to get menu name from database
+    if ($name = db_fetch_array(db_query("SELECT menu_name FROM {menu_links} WHERE link_path = '%s'", $_GET["q"]))) {
+      $active = $name["menu_name"];
+    } else
+      $active = 'navigation';
   }
   return $active;
 }

But it is bad for upgrade Drupal (currently have 6.2)

jhedstrom’s picture

An alternate solution (that worked in my case anyway) was to implement the following via a custom module. The advantage is that no core-hacking is needed:

/**
 * Implementation of hook_init().
 */
function os_custom_init() {
  // Set active menu to Primary, when not on admin pages.
  if (arg(0) != 'admin') {
    menu_set_active_menu_name('primary-links');
  }
}