Browse Source

* Fixed the Inactive Parent anchor name so they all are unique.
* Fixed the Devel menu name and identifier.
* Added support for users to select multiple menus.

Alexis Wilke 15 years ago
parent
commit
4430806082
5 changed files with 49 additions and 6 deletions
  1. 4 3
      simplemenu.admin.inc
  2. 9 0
      simplemenu.install
  3. 31 2
      simplemenu.module
  4. 2 0
      simplemenu_devel.module
  5. 3 1
      simplemenu_inactive_parents.module

+ 4 - 3
simplemenu.admin.inc

@@ -21,12 +21,13 @@ function simplemenu_admin_settings() {
   );
 
   if (module_exists('menu')) {
-    $form['default_menu']['simplemenu_menu'] = array(
+    $form['default_menu']['simplemenu_menus'] = array(
       '#type' => 'select',
+      '#multiple' => TRUE,
       '#title' => t('Menu'),
       '#options' => menu_parent_options(menu_get_menus(), array('mlid' => 0)), // return complete tree
-      '#default_value' => variable_get('simplemenu_menu', 'navigation:0'),
-      '#description' => t('Select the menu to display.'),
+      '#default_value' => variable_get('simplemenu_menus', array('navigation:0')),
+      '#description' => t('Select the menu to display. Select multiple menus to show each one of them (use Ctrl or Shift to select multiple entries.) Please, avoid selecting a parent and a child from the same menu.'),
     );
   }
 

+ 9 - 0
simplemenu.install

@@ -41,4 +41,13 @@ function simplemenu_update_6003() {
   return array();
 }
 
+/**
+ * Implementation of hook_update_N().
+ */
+function simplemenu_update_6004() {
+  // enable multiple menus selection
+  variable_set('simplemenu_menus', array(variable_get('simplemenu_menu', 'navigation:0')));
+  return array();
+}
+
 // vim: ts=2 sw=2 et syntax=php

+ 31 - 2
simplemenu.module

@@ -282,8 +282,37 @@ function simplemenu_get_menu() {
 
   // if a user turned off menu module but SimpleMenu was previously set
   // reset variable so a menu appears
-  $menu_name = module_exists('menu') ? variable_get('simplemenu_menu', 'navigation:0') : 'navigation:0';
-  $tree = simplemenu_menu_tree($menu_name);
+  $all_menus = array('navigation:0');
+  if (module_exists('menu')) {
+    $all_menus = variable_get('simplemenu_menus', $all_menus);
+  }
+  if (count($all_menus) > 1) {
+    // if menu is not enable then we cannot have a count other than 1
+    $menu_titles = menu_get_menus();
+    $tree = array();
+    foreach ($all_menus as $full_name) {
+      list($menu_name, $mlid) = explode(':', $full_name);
+      $tree[] = array(
+        'link' => array(
+          'mlid' => $mlid,
+          'menu_name' => $full_name,
+          'hidden' => FALSE,
+          'title' => $menu_titles[$menu_name],
+          'href' => 'admin/settings/simplemenu', /// ??? -- we should not have a link here
+          'in_active_trail' => FALSE,
+          'has_children' => TRUE,
+          'localized_options' => array(
+            'attributes' => array('class' => 'simplemenu-top-level'),
+          ),
+        ),
+        'below' => simplemenu_menu_tree($full_name),
+      );
+    }
+  }
+  else {
+    reset($all_menus);
+    $tree = simplemenu_menu_tree(current($all_menus));
+  }
 
   // allow other modules to modify the menu tree
   drupal_alter('simplemenu_tree', $tree);

+ 2 - 0
simplemenu_devel.module

@@ -13,6 +13,8 @@ function simplemenu_devel_simplemenu_tree_alter(&$tree) {
   if (user_access('access devel information')) {
     $devel = array(
       'link' => array(
+        'mlid' => 0,
+        'menu_name' => 'devel',
         'hidden' => FALSE,
         'title' => t('Devel module'),
         'href' => 'admin/settings/devel',

+ 3 - 1
simplemenu_inactive_parents.module

@@ -42,10 +42,12 @@ function simplemenu_theme_registry_alter(&$theme_registry) {
  */
 function simplemenu_theme_menu_item_link($link) {
   global $theme;
+  static $cnt = 0;
 
   // this is a drop down?
   if (!empty($link['has_children']) && variable_get('simplemenu_running', FALSE)) {
-    return '<a name="menu-id-' . $link['mlid'] . '">' . $link['title'] . '</a>';
+    ++$cnt;
+    return '<a name="menu-id-' . $cnt . '">' . $link['title'] . '</a>';
   }
 
   // got a theme function?