Index: local_menu/local_menu.module =================================================================== --- local_menu/local_menu.module (revision 108) +++ local_menu.module (working copy) @@ -20,6 +20,13 @@ switch ($op) { case 'configure': + $form['local_menu_default_menu'] = array( + '#type' => 'select', + '#title' => t('Default Menu'), + '#description' => t('Which menu should be shown if an item shows up in more than one menu? Default is Primary Links.'), + '#options' => local_menu_get_menus(), + '#default_value' => variable_get('local_menu_default_menu', 'primary-links'), + ); $form['local_menu_start'] = array( '#type' => 'select', '#title' => t('Starting depth'), @@ -52,6 +59,7 @@ case 'save': variable_set('local_menu_start', $edit['local_menu_start']); + variable_set('local_menu_default_menu', $edit['local_menu_default_menu']); variable_set('local_menu_depth', $edit['local_menu_depth']); return; @@ -72,6 +80,12 @@ // Get the menu link and set the active menu to the menu it's in, so Drupal can find it's way and make correct breadcrumbs at the same time $link = menu_link_load(db_result(db_query("SELECT mlid FROM {menu_links} WHERE link_path = '%s' AND hidden <> 1", $item['href']))); + $mlid = db_result(db_query("SELECT mlid FROM {menu_links} WHERE link_path = '%s' AND hidden <> 1 AND menu_name = '%s'", $item['href'], variable_get('local_menu_default_menu', 'primary-links'))); + if ($mlid) { + $link = menu_link_load($mlid); + } else { + $link = menu_link_load(db_result(db_query("SELECT mlid FROM {menu_links} WHERE link_path = '%s' AND hidden <> 1 AND menu_name != 'admin_menu'", $item['href']))); + } menu_set_active_menu_name($link['menu_name']); // Set current path temporarily to the root of the possible local task we might be, so Drupal finds it's way @@ -164,4 +178,16 @@ return $title; } +/* + * Get an array of all menus + */ +function local_menu_get_menus() { + $result = db_query("SELECT * FROM {menu_custom} ORDER BY title"); + $return = array(); + while ($menu = db_fetch_array($result)) { + $return[$menu['menu_name']] = $menu['title']; + } + return $return; +} + ?> \ No newline at end of file