--- sitemenu-5.x-1.x-dev/sitemenu.module 2007-05-07 05:42:44.000000000 +0200 +++ sitemenu-5.x-1.x-dev.configurableBasePath/sitemenu.module 2007-05-07 05:53:17.000000000 +0200 @@ -19,6 +19,7 @@ define('SITEMENU_AUTHOR_AND_COMMENTS', ' define('SITEMENU_MAX_ROWS', 'sitemenu_max_rows'); define('SITEMENU_FOOTER', 'sitemenu_footer'); define('SITEMENU_BLOCK_VOCAB_TITLES', 'sitemenu_block_vocab_titles'); +define('SITEMENU_LINK_BASE_PATH', 'sitemenu_link_base_path'); function sitemenu_help($section) { switch ($section) { @@ -152,9 +153,39 @@ function sitemenu_settings() { '#description' => t('This text will be displayed at the bottom of the site menu page'), ); + $form[SITEMENU_LINK_BASE_PATH] = array( + '#type' => 'textfield', + '#title' => t('Term link base path'), + '#required' => TRUE, + '#default_value' => variable_get(SITEMENU_LINK_BASE_PATH, 'taxonomy/term/'), + '#size' => 35, + '#maxsize' => 255, + '#description' => t('A base path to which the terms in the site map will link. For each term, the corresponding term ID will be added after the base path. By changing the base path, you can get the terms linking to your custom page (e.g. your custom view) instead of the default taxonomy/term/ page. The trailing slash is required.'), + ); + return system_settings_form($form); } +/** +* Validate sitemenu_settings form +* @param string form id +* @param array form values +*/ +function sitemenu_settings_validate($form_id, $form_values) { + + if ($form_values['op'] != t('Save configuration')) { + return; // only validate on saving! + } + + $link_base_path = $form_values[SITEMENU_LINK_BASE_PATH]; + if (!isset($link_base_path) || (trim($link_base_path) == '')) { + form_set_error(SITEMENU_LINK_BASE_PATH, t('Invalid term link base path.')); + } + if (!preg_match('/\/$/', $link_base_path)) { + form_set_error(SITEMENU_LINK_BASE_PATH, t('A trailing slash is required in the term link base path.')); + } +} + function _sitemenu_contents() { $boxes = _sitemenu_overview('block'); return _sitemenu_print_boxes($boxes, 'block'); @@ -411,7 +442,7 @@ function theme_sitemenu_render_outline($ $path = 'forum/'; break; default: - $path = 'taxonomy/term/'; + $path = variable_get(SITEMENU_LINK_BASE_PATH, 'taxonomy/term/'); break; }