--- site_map.module	Wed Jun 06 10:19:37 2007
+++ site_map.module	Tue Jun 26 17:47:26 2007
@@ -115,13 +115,21 @@ function site_map_admin_settings() {
     '#default_value' => variable_get('site_map_show_count', 1),
     '#description' => t('When enabled, this option will show the number of nodes in each taxonomy term.'),
   );
+  $form['site_map_content_options']['site_map_categories_display_depth'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Display Depth of Categories to include in the site map'),
+    '#default_value' => variable_get('site_map_categories_display_depth', 0),
+    '#size' => 2,
+    '#maxlength' => 2,
+    '#description' => t('Enter the depth of the categories to display on the sitemap, enter 0 to include all depths.'),
+  );
   $form['site_map_content_options']['site_map_categories_depth'] = array(
     '#type' => 'textfield',
-    '#title' => t('Categories depth'),
+    '#title' => t('Categories link depth'),
     '#default_value' => variable_get('site_map_categories_depth', 'all'),
     '#size' => 3,
     '#maxlength' => 10,
-    '#description' => t('Specify how many subcategories should be included on the categorie page. Enter "all" to include all subcategories,"0" to include no subcategories, or "-1" not to append the depth at all.'),
+    '#description' => t('Specify how many subcategories should be included on the categorie page links. Enter "all" to include all subcategories,"0" to include no subcategories, or "-1" not to append the depth at all.'),
   );
 
   $form['site_map_rss_options'] = array(
@@ -421,12 +429,15 @@ function _site_map_taxonomy_tree($vid, $
   if (!is_numeric($cat_depth)) {
     $cat_depth = 'all';
   }
-
+  $max_depth = variable_get('site_map_categories_display_depth', NULL);
+  if (!is_numeric($max_depth) OR !$max_depth) {
+    $max_depth = NULL;
+  }
   $output = $description ? '<div class="description">'. check_plain($description) .'</div>' : '';
 
   $output .= '<div class="tree">';
   // taxonomy_get_tree() honors access controls
-  $tree = taxonomy_get_tree($vid);
+  $tree = taxonomy_get_tree($vid, $parent = 0, $depth = -1, $max_depth);
   foreach ($tree as $term) {
     // Adjust the depth of the <ul> based on the change
     // in $term->depth since the $last_depth.
