diff -dup /var/www/sites/all/modules/menu_trim_bak/1.2-080407/menu_trim.info /var/www/sites/all/modules/menu_trim_bak/alpha3/menu_trim.info --- /var/www/sites/all/modules/menu_trim_bak/1.2-080407/menu_trim.info 2007-06-18 20:19:22.000000000 -0400 +++ /var/www/sites/all/modules/menu_trim_bak/alpha3/menu_trim.info 2008-04-18 15:57:09.000000000 -0400 @@ -1,9 +1,8 @@ -; $Id: menu_trim.info,v 1.2 2007/06/18 22:53:49 dww Exp $ +; $Id name = Menu Trim description = "Allows menu hierarchies to be trimmed when navigated." -; Information added by drupal.org packaging script on 2007-06-19 -version = "5.x-1.x-dev" +; Information added by drupal.org packaging script on 2008-04-18 +version = "5.x-2.alpha2" project = "menu_trim" -datestamp = "1182212362" diff -dup /var/www/sites/all/modules/menu_trim_bak/1.2-080407/menu_trim.install /var/www/sites/all/modules/menu_trim_bak/alpha3/menu_trim.install --- /var/www/sites/all/modules/menu_trim_bak/1.2-080407/menu_trim.install 2007-01-12 19:59:05.000000000 -0500 +++ /var/www/sites/all/modules/menu_trim_bak/alpha3/menu_trim.install 2008-04-21 23:26:52.000000000 -0400 @@ -1,10 +1,92 @@ name); + $var_data = variable_get($var->name, NULL); + // Menu item insertion + $ret[] = update_sql("INSERT INTO {menu_trim} (mid, trim) VALUES (". $var_id .", ". $var_data .")"); + } + + // Upon succesful update, delete the corresponding previous version entry + $vars = db_query("SELECT mid FROM {menu_trim}"); + // Iterate trimmable items + while ($var = db_fetch_object($vars)) { + if ($var->mid) { + variable_del('menu_trim_item_'. $var->mid); + } + } + + // Update setting items + $menu = array(); + $vars = db_query("SELECT name FROM {variable} WHERE name LIKE 'menu_trim_menu_%%'"); + // Iterate setting items + while ($var = db_fetch_object($vars)) { + $var_id = str_replace('menu_trim_menu_', '', $var->name); + $var_data = variable_get($var->name, MENU_TRIM_DISABLED); + // based on : menu_trim_admin_settings_submit and _menu_trim_settings_set + $menu[$var_id] = array('method' => $var_data, 'root_title' => 1, 'min_level' => '', 'min_limit' => 0); + } + variable_set('menu_trim', $menu); + + // Delete old setting items + $vars = variable_get('menu_trim', NULL); + // Iterate setting items + if (is_array($vars)) { + foreach ($vars as $var_id => $var_data) { + variable_del('menu_trim_menu_'. $var_id); + } + } + + // Clear the variables cache as some should've been deleted + cache_clear_all('variables', 'cache'); + + return $ret; +} + diff -dup /var/www/sites/all/modules/menu_trim_bak/1.2-080407/menu_trim.module /var/www/sites/all/modules/menu_trim_bak/alpha3/menu_trim.module --- /var/www/sites/all/modules/menu_trim_bak/1.2-080407/menu_trim.module 2007-01-12 19:59:05.000000000 -0500 +++ /var/www/sites/all/modules/menu_trim_bak/alpha3/menu_trim.module 2008-04-21 23:30:33.000000000 -0400 @@ -2,38 +2,54 @@ // $Id: menu_trim.module,v 1.2 2007/01/13 00:59:05 davidlesieur Exp $ /** - * @file Allows menu hierarchies to be trimmed when navigated. By trimming, here - * we mean skipping the display of parent menu items when any of some designated - * items becomes active. - * - * At the simplest level, this module allows to hide a menu until some of its - * items has become the active item (by reaching the corresponding url). This is - * easier than configuring the menu's block visibility for each possible path - * contained in the menu. - * - * This module can be used to make a "contextual secondary menu" based on the - * primary links (e.g. you set the Primary links menu for "Allow trimming for - * this menu, hide menu when no item is active", activate the "Primary links - * (menu_trim)" block, then edit the menu's top-level items and check the "Trim - * parent items" option). After that, when an item is selected in the primary - * links, the contextual menu will appear, showing only the subitems of the - * selected item. Drupal already allows contextual "secondary links" based on - * the primary links, but these secondary links are limited to a depth of one - * level. Menu Trim, on the other hand, can display complete menu subtrees. - * - * This module can also be used in any menu to trim parents when reaching deep - * menu items. This can make deep menus more usable, and the breadcrumb will - * still show the full path. + * @file + * Add alternative menu blocks that add the possibility of trimming + * some of the top of it's hierarchy so it would start displaying from + * certain menu items or from a whole level (ex: tertiary). + * + * @author David Lesieur + * @author William Carrier */ -// TODO: When a menu item is deleted, remove the corresponding menu_trim_item_mid variable, if any. - -define ('MENU_TRIM_DISABLED', 0); +// TODO: When a menu item is deleted, remove the corresponding entries, if any. // TODO: Add a system to reduce the load in the search of other menu items up the menu tree which requires CPU and DB hits. +// TODO: Look at menu.modules or default menu blocks for the default Root Title. + +// Trimming methods +define ('MENU_TRIM_DISABLED', 0); define ('MENU_TRIM_ENABLED_SHOW_MENU_ALWAYS', 1); -define ('MENU_TRIM_ENABLED_SHOW_MENU_ACTIVE', 2); +define ('MENU_TRIM_ENABLED_SHOW_MENU_ACTIVE', 2); + +/** + * Implementation of hook_help(). + */ +function menu_trim_help($section) { + switch ($section) { + case 'admin/help#menu_trim': + $output = '

'. t('The menu trim module create copies of menu blocks allowing user with menu modification permissions to trim its parent menus.') .'

'; + $output .= '

'. t('To make trimmed menus, you must first select the module behavior for each menus in the module settings. Then you need to select appropriately the Trim parent items option in the menus to enable trimming its parents. At last, you need to display the menu trim blocks. Now when reaching the enabled menu items, its parents should be trimmed.', array('@settings' => 'admin/settings/menu_trim')) .'

'; + $output .= '

'. t('For more information please refer to the project page.', array('@project' => 'http://drupal.org/project/menu_trim')) .'

'; + return $output; + case 'admin/settings/menu_trim': + $output = '

'. t('Choose the menus that need to be trimmed. Each of the menus where trimming is allowed will get a corresponding Menu trim block with appropriate options. You should then enable those blocks, and edit the menu items to Trim parent items.', array('@enable' => url('admin/build/block')), array('@edit' => url('admin/build/menu'))) .'

'; + $output .= '

'. t('For example, if you want to show items in its trimmable menu only starting at secondary links, you show edit the primary links with it\'s level at 2 and having its limit checked.') .'

'; + $output .= '
'. t('Options definitions :'); + $output .= '
'. t('Trim Method') .'
'; + $output .= '
'. t('Allow trimming will display a root menu by default.') .'
'; + $output .= '
'. t('Root Title') .'
'; + $output .= '
'. t('Enables a title when displaying a root menu.') .'
'; + $output .= '
'. t('Min. Level') .'
'; + $output .= '
'. t('A minimum level from which starting displaying a menu by default.') .'
'; + $output .= '
'. t('Limit') .'
'; + $output .= '
'. t('Won\'t allow trimmable items to trim under its menu minimum level.') .'
'; + $output .= '
'; + return $output; + } +} /** - * Implementation for hook_menu(). + * Implementation for hook_menu(). + * + * @see menu_trim_admin_settings() */ function menu_trim_menu($may_cache) { $items = array(); @@ -41,126 +57,300 @@ function menu_trim_menu($may_cache) { if ($may_cache) { $items[] = array( 'path' => 'admin/settings/menu_trim', - 'title' => t('Menu trim'), + 'title' => t('Menu Trim'), 'description' => t('Choose what menus need trimming.'), 'callback' => 'drupal_get_form', 'callback arguments' => array('menu_trim_admin_settings'), - 'access' => user_access('administer site configuration'), + 'access' => user_access('administer menu trim'), 'type' => MENU_NORMAL_ITEM, ); } - return $items; } + +/** + * Implementation of hook_perm(). + */ +function menu_trim_perm() { + return array('administer menu trim'); +} /** - * Administration page callback. + * Administration page callback. + * + * @see theme_menu_trim_admin_settings() + * @see menu_trim_admin_settings_validate() + * @see menu_trim_admin_settings_submit() */ function menu_trim_admin_settings() { - $form['menu_trim'] = array( - '#type' => 'fieldset', - '#title' => t('Trim menus'), - '#description' => t('Choose the menus that need to be trimmed. Each of the menus where trimming is allowed will get a corresponding Menu trim block. You should then !enable, and !edit that need to have their parents trimmed.', array('!enable' => l(t('enable those blocks'), 'admin/build/block'), '!edit' => l(t('edit the menu items'), 'admin/build/menu'))), - ); - - $menus = menu_get_root_menus(); - foreach ($menus as $mid => $title) { - $form['menu_trim']['menu_trim_menu_'. $mid] = array( - '#type' => 'select', + $menu_list = menu_get_root_menus(); + $menu_fetched = variable_get('menu_trim', NULL); + $menu = is_array($menu_fetched) ? $menu_fetched : array(); + + foreach ($menu_list as $mid => $title) { + $form[$mid] = array( + '#tree' => TRUE, + ); + $form[$mid]['title'] = array( + '#type' => 'item', '#title' => check_plain($title), + ); + $form[$mid]['method'] = array( + '#type' => 'select', '#options' => array( - MENU_TRIM_DISABLED => t('Never trim this menu'), - MENU_TRIM_ENABLED_SHOW_MENU_ALWAYS => t('Allow trimming of this menu'), - MENU_TRIM_ENABLED_SHOW_MENU_ACTIVE => t('Allow trimming of this menu, hide menu when no item is active'), + MENU_TRIM_DISABLED => t('Never trim'), + MENU_TRIM_ENABLED_SHOW_MENU_ALWAYS => t('Allow trimming'), + MENU_TRIM_ENABLED_SHOW_MENU_ACTIVE => t('Allow trimming, hide when inactive'), ), - '#default_value' => variable_get('menu_trim_menu_'. $mid, MENU_TRIM_DISABLED), - ); + '#default_value' => $menu[$mid]['method'] ? $menu[$mid]['method'] : MENU_TRIM_DISABLED, + ); + $form[$mid]['root_title'] = array( + '#type' => 'checkbox', + '#default_value' => $menu[$mid]['root_title'] ? $menu[$mid]['root_title'] : FALSE, + ); + $form[$mid]['min_level'] = array( + '#type' => 'textfield', + '#default_value' => $menu[$mid]['min_level'], + '#size' => 2, + '#maxlength' => 2, + ); + $form[$mid]['min_level_limit'] = array( + '#type' => 'checkbox', + '#default_value' => $menu[$mid]['min_level_limit'] ? $menu[$mid]['min_level_limit'] : FALSE, + ); } - return system_settings_form($form); } - + +/** + * Format the settings form. + * + * Makes a table separating each menu by row. + */ +function theme_menu_trim_admin_settings($form) { + $rows = array(); + foreach ($form as $key => $element) { + $title1 = $element['title']; + if (is_array($title1) && $title1['#type'] == 'item') { + $rows[] = array(drupal_render($form[$key]['title']), drupal_render($form[$key]['method']), drupal_render($form[$key]['root_title']), drupal_render($form[$key]['min_level']), drupal_render($form[$key]['min_level_limit'])); + } + } + // First item must have colspan to include hidden items + $header = array(array('data' => t('Menu')), array('data' => t('Trim Method')), array('data' => t('Root Title')), array('data' => t('Min. Level')), array('data' => t('Limit'))); + $output = theme('table', $header, $rows); + $output .= drupal_render($form); + return $output; +} + +/** + * Form API callback to validate the settings form. + * + * Validate the textfield min_level. + */ +function menu_trim_admin_settings_validate($form_id, $form_values) { + foreach ($form_values as $key => $element) { + // Validate minimum level field + if (is_array($element)) { + // Validation must be made in 2 steps or it might skip 0 + if (is_numeric($element['min_level'])) { + if ($element['min_level'] <= 0) { + form_set_error($key .'][min_level', t('The minimum level must be an integer greater than zero.')); + } + } + elseif ($element['min_level']) { + form_set_error($key .'][min_level', t('The minimum level must be an integer greater than zero.')); + } + } + } +} + +/** + * Form API callback to submit the settings form. + * + * Save language settings in variable + */ +function menu_trim_admin_settings_submit($form_id, $form_values) { + $menu = array(); + foreach ($form_values as $key => $element) { + // Find appropriate element + if (is_array($element)) { + $menu[$key] = array('method' => $element['method'], 'root_title' => $element['root_title'], 'min_level' => $element['min_level'], 'min_level_limit' => $element['min_level_limit']); + } + } + variable_set('menu_trim', $menu); + $menu_set = !db_error(); + if (!$menu_set) { + drupal_set_message(t('The settings did not save properly.'), 'error'); + } +} + /** * Implementation of hook_block(). */ -function menu_trim_block($op = 'list', $delta = 0, $edit = array()) { +function menu_trim_block($op = 'list', $delta = 0, $edit = array()) { switch ($op) { + /** + * Display the alternative menus for which respective methods aren't disabled. + */ case 'list': $blocks = array(); - $menus = menu_get_root_menus(); - foreach ($menus as $mid => $title) { - if (variable_get('menu_trim_menu_'. $mid, MENU_TRIM_DISABLED) != MENU_TRIM_DISABLED) { - $blocks[$mid]['info'] = check_plain($title) .' ('. t('Menu trim') .')'; + $menu = variable_get('menu_trim', NULL); + if (is_array($menu)) { + $root_menus = menu_get_root_menus(); + foreach ($root_menus as $mid => $title) { + if ($menu[$mid] && $menu[$mid]['method'] != MENU_TRIM_DISABLED) { + $blocks[$mid]['info'] = check_plain($title) .' ('. t('Menu Trim') .')'; + } } } return $blocks; - - case 'view': - if (($mode = variable_get('menu_trim_menu_'. $delta, MENU_TRIM_DISABLED)) != MENU_TRIM_DISABLED) { - // Get the trail of the active item in the $delta menu. If the active - // item is not in that menu, the menu won't be shown at all. - $trail = _menu_get_active_trail_in_submenu($delta); - if (is_array($trail)) { - // The active item is child of this menu, check for trimming - while ($mid = array_pop($trail)) { - if (variable_get('menu_trim_item_'. $mid, FALSE)) { - // Show the menu using the item as root - $item = menu_get_item($mid); - $data['subject'] = check_plain($item['title']); - $data['content'] = theme('menu_tree', $mid); - break; - } - } - if (!$data) { - // No trim flag found in the trail, show the full menu + /** + * The workflow of the block display is that it start by looking for a minimum + * level and if there isn't one it simply look for selected items (as version + * 1.0), if there's one it will compare the active trail level with the minimum + * level ; if it's smaller, it will only display if it isn't a limit and a + * selected item is found, if it's higher it will be cropped to the minimum + * then go through as if it was the same as the minimum which will display if + * it's a limit or if it isn't will note the minimum level values and search + * for a selected item and if one is found it's displayed but if none was found + * the minimum level is displayed. + * + * In all cases if nothing is to be displayed and the chosen method is to have + * the root menu displayed by default, it does that. + */ + case 'view': + $data = array(); + $menu = variable_get('menu_trim', NULL); + if (is_array($menu)) { + if ($menu[$delta]['method']) { // disabled is 0 so it won't pass + $trail = _menu_get_active_trail_in_submenu($delta); + if (is_array($trail)) { + array_shift($trail); // Remove trail root menu item + $level = isset($menu, $delta, $menu[$delta]['min_level']) ? $menu[$delta]['min_level'] : NULL; + // Verify if there's a minimum level + if (!is_numeric($level)) { + while ($mid = array_pop($trail)) { if (db_result(db_query("SELECT trim FROM {menu_trim} WHERE mid=%d", $mid))) { + $item = menu_get_item($mid); + $data['subject'] = check_plain($item['title']); + $data['content'] = theme('menu_tree', $mid); + break; + } + } + } + else { + // Verify if the level is lesser than its minimum + if (count($trail) < $level) { + // Verify if menu hasn't a limit + if (!$menu[$delta]['min_level_limit']) { + while ($mid = array_pop($trail)) { + if (db_result(db_query("SELECT trim FROM {menu_trim} WHERE mid=%d", $mid))) { + $item = menu_get_item($mid); + $data['subject'] = check_plain($item['title']); + $data['content'] = theme('menu_tree', $mid); + break; } + } + } + } + else { + // Verify if the level is greater than its minimum + if (count($trail) > $level) { // Trail includes menu item + array_splice($trail, $level); + } + // Level is at its minimum, by elimination + // Retreive minimum level id + $mid = array_pop($trail); + // Verify if menu has a limit + if ($menu[$delta]['min_level_limit']) { + $item = menu_get_item($mid); + $data['subject'] = check_plain($item['title']); + $data['content'] = theme('menu_tree', $mid); + } + else { + // Save the minimum level id in case there's no selected item up the branch + $limit_mid = $mid; + do { + if (db_result(db_query("SELECT trim FROM {menu_trim} WHERE mid=%d", $mid))) { + $item = menu_get_item($mid); + $data['subject'] = check_plain($item['title']); + $data['content'] = theme('menu_tree', $mid); + break; } + } while ($mid = array_pop($trail)); + // Verify there wasn't any selected item up the branch + if (!$data) { + $item = menu_get_item($limit_mid); + $data['subject'] = check_plain($item['title']); + $data['content'] = theme('menu_tree', $limit_mid); + } + } + } + } + } + // Verify if nothing is to be displayed and the chosen method is to have the root menu displayed by default if (!$data && $menu[$delta]['method'] == MENU_TRIM_ENABLED_SHOW_MENU_ALWAYS) { + // Show the menu using root item as base $item = menu_get_item($delta); - $data['subject'] = check_plain($item['title']); + $data['subject'] = $menu[$delta]['root_title'] ? check_plain($item['title']) : ''; $data['content'] = theme('menu_tree', $delta); } } - elseif ($mode == MENU_TRIM_ENABLED_SHOW_MENU_ALWAYS) { - // The active item is not child of this menu, show the plain menu - $item = menu_get_item($delta); - $data['subject'] = check_plain($item['title']); - $data['content'] = theme('menu_tree', $delta); - } - // Otherwise, $mode == MENU_TRIM_ENABLED_MENU_SHOW_ACTIVE, do not show - // the menu since it has to be shown only when it contains an active - // item } return $data; } } /** - * Implementation of hook_form_alter(). + * Implementation of hook_form_alter(). + * + * @param $form need to be passed by referrence + * + * @see menu_trim_edit_item_form_submit() */ function menu_trim_form_alter($form_id, &$form) { if ($form_id == 'menu_edit_item_form') { + $menu = variable_get('menu_trim', NULL); $mid = $form['mid']['#value']; - $item = menu_get_item($mid); - // Check if this item is in a menu that is set for trimming - while ($item['pid']) { - $root_mid = $item['pid']; - $item = menu_get_item($item['pid']); - } - if (variable_get('menu_trim_menu_'. $root_mid, MENU_TRIM_DISABLED) != MENU_TRIM_DISABLED) { - $form['trim_item'] = array( - '#type' => 'checkbox', - '#title' => t('Trim parent items.'), - '#description' => t('Check this option to trim the parent items when this item or any of its children becomes active.') .'
'. t('Trimming applies only to the menu\'s corresponding Menu trim !block, not to its normal block. When trimming occurs, this item\'s title will become the menu\'s title. Note also that if this item has no children, has its parents trimmed, and becomes active, then no menu will be displayed at all since such menu would be empty.', array('!block' => l(t('block'), 'admin/build/block'))), - '#default_value' => variable_get('menu_trim_item_'. $mid, FALSE), - '#weight' => 1, - ); - $form['#submit']['menu_trim_edit_item_form_submit'] = current($form['#submit']); - - // Make sure the button remains at the form's bottom - $form['submit']['#weight'] = 10; + // Initialisation verification if (isset($menu, $mid)) { + $item = menu_get_item($mid); + // Retreive root menu, based on _menu_get_active_trail() while ($item['pid']) { + $root = $item['pid']; + $item = menu_get_item($item['pid']); + } + // Verify if current item root has trimming enabled + if ($menu[$root]['method'] != MENU_TRIM_DISABLED) { + $form['trim'] = array( + '#type' => 'checkbox', + '#title' => t('Trim parent items'), + '#description' => t('Check this option to trim the parent items when this item or any of its children becomes active in its menu Menu trim corresponding block, not its default one.', array('@block' => url('admin/build/block'))) . theme_more_help_link('admin/help/menu_trim'), + '#default_value' => db_result(db_query("SELECT trim FROM {menu_trim} WHERE mid=%d", $mid)), + '#weight' => 1, + ); + $form['#submit']['menu_trim_edit_item_form_submit'] = current($form['#submit']); + // Make sure the button remains at the form's bottom $form['submit']['#weight'] = 10; + } } } } -function menu_trim_edit_item_form_submit($form_id, $form_values) { - variable_set('menu_trim_item_'. $form_values['mid'], $form_values['trim_item']); -} - +/** + * Form submittion customization for edit_item_form. + * The parameters are the same of the calling function menu_trim_form_alter. + */ +function menu_trim_edit_item_form_submit($form_id, $form_values) { + // Form validation + if (isset($form_values['trim'])) { + // Menu trimming option saving and verification + db_lock_table('menu_trim'); + $db_result_1 = db_result(db_query("SELECT mid FROM {menu_trim} WHERE mid=%d", $form_values['mid'])); + // Entry verification + if ($db_result_1) { + $db_result_2 = db_query("UPDATE {menu_trim} SET trim=%d WHERE mid=%d", $form_values['trim'], $form_values['mid']); + } + else { + $db_result_2 = db_query("INSERT INTO {menu_trim} (mid, trim) VALUES (%d, %d)", $form_values['mid'], $form_values['trim']); + } + if (db_error() || !$db_result_2) { + drupal_set_message(t('A database issue prevented Menu trim to modify its status for the menu %menu.', array('%menu' => $form_values['mid'])), 'error'); + } + db_unlock_tables(); + } +} + diff -dup /var/www/sites/all/modules/menu_trim_bak/1.2-080407/README.txt /var/www/sites/all/modules/menu_trim_bak/alpha3/README.txt --- /var/www/sites/all/modules/menu_trim_bak/1.2-080407/README.txt 2007-01-12 19:59:05.000000000 -0500 +++ /var/www/sites/all/modules/menu_trim_bak/alpha3/README.txt 2008-04-18 15:12:32.000000000 -0400 @@ -1,64 +1,80 @@ -README file for the Menu Trim Drupal module. - - -Description -*********** - -The Menu Trim module allows menu hierarchies to be trimmed when navigated. By -trimming, here we mean skipping the display of parent menu items when any of -some designated items becomes active. - -At the simplest level, this module allows to hide a menu until some of its items -has become the active item (by reaching the corresponding url). This is easier -than configuring the menu's block visibility for each possible path contained in -the menu. - -This module can be used to make a "contextual secondary menu" based on the -primary links (e.g. you set the Primary links menu for "Allow trimming for this -menu, hide menu when no item is active", activate the "Primary links -(Menu trim)" block, then edit the menu's top-level items and check the "Trim -parent items" option). After that, when an item is selected in the primary -links, the contextual menu will appear, showing only the subitems of the -selected item. Drupal already allows contextual "secondary links" based on the -primary links, but these secondary links are limited to a depth of one -level. Menu Trim, on the other hand, can display complete menu subtrees. - -This module can also be used in any menu to trim parents when reaching deep menu -items. This can make deep menus more usable, and the breadcrumb will still show -the full path. - - -Compatibility -************* - -This module has been tested on Drupal 4.7.4 and 5.0 RC2. - - -Installation -************ - -1. Extract the 'menu_trim' module directory into your Drupal modules directory. - -2. Enable the Menu Trim module on your site's Administer > Site building > - Modules page. - -3. Go to Administer > Site configuration > Menu trim, and configure some menus - to allow trimming. Select "Allow trimming for this menu, hide menu when no - item is active" if you not only want a menu to be trimmed on some designated - items, but to also make it "contextual" (appearing only when url matching - some of its items is requested). - -4. Go to Administer > Site building > Blocks, and enable the "Menu trim" blocks - for each of the menus for which trimming was allowed. - -5. Go to Administer > Site building > Menus, and edit each item that needs its - parents to be trimmed by checking "Trim parent items" in the item's edit - form. - - +README file for the Menu Trim Drupal module. + + +Description +*********** + +The Menu Trim module allows menu hierarchies to be trimmed when navigated. By +trimming, here we mean skipping the display of parent menu items when any of +some designated items becomes active. + +At the simplest level, this module allows to hide a menu until some of its items +has become the active item (by reaching the corresponding url). This is easier +than configuring the menu's block visibility for each possible path contained in +the menu. + +This module can be used to make a "contextual secondary menu" based on the +primary links (e.g. you set the Primary links menu for "Allow trimming for this +menu, hide menu when no item is active", activate the "Primary links +(Menu trim)" block, then edit the menu's top-level items and check the "Trim +parent items" option). After that, when an item is selected in the primary +links, the contextual menu will appear, showing only the subitems of the +selected item. Drupal already allows contextual "secondary links" based on the +primary links, but these secondary links are limited to a depth of one +level. Menu Trim, on the other hand, can display complete menu subtrees. + +A new feature for version 2.0 has been the automation of trimming a menu dept so +instead of choosing a specific dept, let's say the third, instead of going to +the menu and selecting each menu item on the third level, you simply need to go +to Menu Trim settings and at the menu row enter "3" in the Min. Level column ; +this also save you the hassle of selecting the third level items of added menu +branches. The minimum level also has the ability of being a trimming limit so if +an item is selected with a dept lower than it, it won't be displayed as trimmed. +Another feature is to toggle the display of the title for the default root menu +with the option Root Title. + +This module can also be used in any menu to trim parents when reaching deep menu +items. This can make deep menus more usable, and the breadcrumb will still show +the full path. + + +Installation +************ + +1. Extract the 'menu_trim' module directory into your Drupal modules directory. + +2. Enable the Menu Trim module on your site's Administer > Site building > + Modules page. + +3. Go to Administer > Site configuration > Menu trim, and configure some menus + to allow trimming. Select "Allow trimming, hide when inactive" if you not + only want a menu to be trimmed on some designated items, but to also make it + "contextual" (appearing only when the url is matching some of its items is + requested). If you desire a different title behavior for root menus, un/check + the Root Title box. If desired, choose a minimum level from which trimming + start and if you don't want any item to trim before it, check the Limit box. + +4. Go to Administer > Site building > Blocks, and enable the "Menu trim" blocks + for each of the menus for which trimming was allowed. + +5. Go to Administer > Site building > Menus, and edit each item that needs its + parents to be trimmed by checking "Trim parent items" in the item's edit + form. + Credits ******* + +Version 1.0 +----------- David Lesieur, http://davidlesieur.com. -This module was developed for a client of Koumbit.org (http://koumbit.org). +Initially developed on behalf of Koumbit.org (http://koumbit.org). + +Version 2.0 +----------- + +William Carrier, http://www.williamcarrier.com. + +Upgrade slighty sponsored by Koumbit.org (http://koumbit.org). +