Index: README.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/menutree/README.txt,v retrieving revision 1.2.2.2 diff -u -p -r1.2.2.2 README.txt --- README.txt 19 Apr 2007 19:24:41 -0000 1.2.2.2 +++ README.txt 25 Aug 2007 18:23:58 -0000 @@ -2,15 +2,15 @@ ABOUT This module provides two menu-based features: a sitemap page and a jump menu. -First, this module provides a nested unordered list representation of a complete -Drupal menu structure. menutree/1 provides a tree representation of menu 1, -menutree/2 provides a tree representation of menu 2, etc. If no ID is +First, this module provides a nested unordered list representation of a +complete Drupal menu structure. menutree/1 provides a tree representation of +menu 1, menutree/2 provides a tree representation of menu 2, etc. If no ID is specified, the primary_links menu is used. That allows it to be used as a simple menu-based sitemap, give or take a path alias. -Second, it provides a block for each menu in the system that provides a "jump menu". -A jump menu is a select box of a menu from which users can select any menu item -to be redirected straight to that page. (Drupal 5 version only) +Second, it provides a block for each menu in the system that provides a "jump +menu". A jump menu is a select box of a menu from which users can select any +menu item to be redirected straight to that page. (Drupal 5 version only) REQUIREMENTS @@ -20,7 +20,10 @@ INSTALLATION - Copy the menutree directory to your modules directory. - Go to admin/build/modules and enable it. -- Everything else is handled by the miracle of Drupal's automated install system. +- Go to admin/settings/menutree to optionally set a page title and intro text + for menutree (sitemap) pages. +- Everything else is handled by the miracle of Drupal's automated install + system. AUTHOR AND CREDIT @@ -28,5 +31,5 @@ Larry Garfield garfield@palantir.net http://www.palantir.net/ -This module was initially developed by Palantir.net for artsci.washu.edu, and released to the Drupal -community under the GNU General Public License v2. +This module was initially developed by Palantir.net for artsci.washu.edu, and +released to the Drupal community under the GNU General Public License v2. Index: menutree.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/menutree/menutree.module,v retrieving revision 1.2.2.3 diff -u -p -r1.2.2.3 menutree.module --- menutree.module 15 Jun 2007 23:11:57 -0000 1.2.2.3 +++ menutree.module 25 Aug 2007 19:23:49 -0000 @@ -15,7 +15,7 @@ * Implementation of hook_perm(). */ function menutree_perm() { - return array('view site tree'); + return array('view site tree', 'administer menu tree'); } /** @@ -32,12 +32,73 @@ function menutree_menu($may_cache) { 'callback' => 'menutree_display', 'type' => MENU_CALLBACK, ); + $items[] = array( + 'path' => 'admin/settings/menutree', + 'title' => t('Menu Tree'), + 'access' => user_access('administer menu tree'), + 'callback' => 'drupal_get_form', + 'callback arguments' => 'menutree_settings', + ); } return $items; } /** + * Display menutree settings form. + */ +function menutree_settings() { + $form = array(); + + $form['menutree'] = array('#tree' => TRUE); + + $menus = menu_get_root_menus(); + foreach ($menus as $mid => $menu) { + $values = variable_get('menutree_'. $mid, array()); + + $form['menutree'][$mid] = array( + '#type' => 'fieldset', + '#title' => $menu, + '#collapsible' => TRUE, + '#collapsed' => (!empty($values['title']) || !empty($values['intro_text']) ? FALSE : TRUE), + ); + $form['menutree'][$mid]['title'] = array( + '#type' => 'textfield', + '#title' => t('Page title'), + '#default_value' => (isset($values['title']) ? $values['title'] : ''), + '#description' => t('A page title that is displayed instead of the root menu item title.'), + ); + $form['menutree'][$mid]['intro_text'] = array( + '#type' => 'textarea', + '#title' => t('Intro text'), + '#default_value' => (isset($values['intro_text']) ? $values['intro_text'] : ''), + '#resizable' => TRUE, + '#description' => t('An intro text that is displayed below the page title.'), + ); + } + + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Save'), + ); + + return $form; +} + +function menutree_settings_submit($form_id, $form_values) { + foreach ($form_values['menutree'] as $mid => $values) { + if (!empty($values['title']) || !empty($values['intro_text'])) { + variable_set('menutree_'. $mid, $values); + } + else { + variable_del('menutree_'. $mid); + } + } + + drupal_set_message(t('Menu Tree settings have been saved.')); +} + +/** * Display a fully-expanded version of the menu specified on the path * * @param int $pid @@ -55,9 +116,26 @@ function menutree_display($pid = 0) { if (empty($menu)) { drupal_not_found(); } - drupal_set_title(check_plain($menu['title'])); + + $values = variable_get('menutree_'. $pid, 0); + if ($values) { + // Output custom page title. + if (!empty($values['title'])) { + drupal_set_title(check_plain($values['title'])); + } + else { + drupal_set_title(check_plain($menu['title'])); + } + + // Output custom intro text. + if (!empty($values['intro_text'])) { + $output .= check_markup($values['intro_text'], FILTER_FORMAT_DEFAULT, FALSE); + } + } $tree = theme('menutree_tree', $pid); - return theme('menutree_page', $tree); + $output .= theme('menutree_page', $tree); + + return $output; } /**