--- local_menu.module	Wed Sep 23 10:08:26 2009
+++ local_menu.module	Wed Sep 23 10:08:20 2009
@@ -46,11 +46,24 @@
       ),
       '#default_value' => variable_get('local_menu_depth', LOCAL_MENU_UNLIMITED),
     );
+	$names = array();
+    $result = db_query("SELECT DISTINCT(menu_name) FROM {menu_links} ORDER BY menu_name");
+    while ($name = db_fetch_array($result)) {
+      $names[$name['menu_name']] = $name['menu_name'];
+    }
+	$form['local_menu_exclusions'] = array(
+      '#type' => 'checkboxes',
+      '#title' => t('Menus to exlude by machine readable name'),
+      '#description' => t('Check the menus to exclude. These are listed by their machine readable name.'),
+	  '#options' => $names,
+      '#default_value' => variable_get('local_menu_exclusions', array(null)),
+    );
     return $form;
   }
   elseif ($op == 'save') {
     variable_set('local_menu_start', $edit['local_menu_start']);
     variable_set('local_menu_depth', $edit['local_menu_depth']);
+	variable_set('local_menu_exclusions', $edit['local_menu_exclusions']);
   }
   elseif ($op == 'view') {
     $item = menu_get_item();
@@ -68,15 +81,16 @@
 
     // 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
     $result = db_query("SELECT mlid FROM {menu_links} WHERE link_path = '%s' AND hidden <> 1 AND menu_name NOT IN ('admin_menu', 'devel')", $item['href']);
-
     // In case there are multiple, let's find the most appropriate one
-    while ($link = menu_link_load(db_result($result))) {
 
-      if (in_array($link['menu_name'], array(
+    while ($link = menu_link_load(db_result($result))) {
+	 if (in_array($link['menu_name'], array(
             variable_get('menu_primary_links_source', 'primary-links'),
             variable_get('menu_secondary_links_source', 'secondary-links'),
             menu_get_active_menu_name(),
-          ))) {
+          )) &&
+		  !in_array( $link['menu_name'], array_values(array_filter(variable_get('local_menu_exclusions', NULL))) )
+		  ) {
         break;
       }
     }
