Index: site_map.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/site_map/site_map.module,v
retrieving revision 1.39.2.17.2.4
diff -u -p -r1.39.2.17.2.4 site_map.module
--- site_map.module	28 Dec 2009 14:32:26 -0000	1.39.2.17.2.4
+++ site_map.module	29 Jan 2010 19:04:14 -0000
@@ -493,11 +493,20 @@ function _site_map_taxonomy_tree($vid, $
     // Display the $term.
     $output .= "\n<li>";
     $term_item = '';
-    if ($forum_link) {
-      $term_item .= l($term->name, 'forum/'. $term->tid, array('attributes' => array('title' => $term->description)));
+    // Work out if the term path is being overridden.
+    $raw_path = 'taxonomy/term/'. $term->tid;
+    $term_path = taxonomy_term_path($term);
+    // Compile the feed URL.  If the term path is not being overridden the
+    // depth can be added.
+    if ($raw_path == $term_path) {
+      $feed_path = $term_path .'/'. $cat_depth .'/feed';
     }
-    else if ($term->count) {
-      $term_item .= l($term->name, ($cat_depth < 0) ? taxonomy_term_path($term) : "taxonomy/term/$term->tid/$cat_depth", array('attributes' => array('title' => $term->description)));
+    else {
+      $feed_path = $term_path .'/feed';
+    }
+    // Only create an actual link if there is content tagged with this item.
+    if ($term->count) {
+      $term_item .= l($term->name, $term_path, array('attributes' => array('title' => $term->description)));
     }
     else {
       $term_item .= check_plain($term->name);
@@ -507,7 +516,8 @@ function _site_map_taxonomy_tree($vid, $
     }
 
     if (variable_get('site_map_show_rss_links', 1) != 0) {
-      $rss_link = theme('site_map_feed_icon', "taxonomy/term/$term->tid/$rss_depth/feed");
+      // Use the term_path generated earlier.
+      $rss_link = theme('site_map_feed_icon', $feed_path);
       if (module_exists('commentrss') && variable_get('commentrss_term', FALSE)) {
         $rss_link .= ' '. theme('site_map_feed_icon', "crss/term/$term->tid", 'comment');
       }
