Index: relatedlinks.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/relatedlinks/relatedlinks.module,v
retrieving revision 1.15
diff -u -r1.15 relatedlinks.module
--- relatedlinks.module	9 Oct 2006 09:07:33 -0000	1.15
+++ relatedlinks.module	11 Oct 2006 13:16:20 -0000
@@ -186,7 +186,9 @@
               $terms = array();
               // Only get the terms if this link type is enabled.
               if (in_array('taxonomy', variable_get('relatedlinks_types', array('parsed')))) {
-                $terms = _relatedlinks_get_terms(array_keys($node->taxonomy), $node->nid);
+	        foreach (variable_get('relatedlinks_node_types', array()) as $node_type) {
+                  $terms[$node_type] = _relatedlinks_get_terms(array_keys($node->taxonomy), $node->nid, $node_type);
+		}
               }
 
               // If there are any links, display them.
@@ -198,7 +200,12 @@
                   $block['content'] = theme('relatedlinks', $links);
                 }
                 if (!empty($terms)) {
-                  $block['content'] .= theme('relatedlinks', $terms, 'Related Terms');
+		  $node_types = node_get_types();
+		  foreach ($terms as $node_type => $term) {
+                    if(!empty($term)) {
+		      $block['content'] .= theme('relatedlinks', $term, $node_types[$node_type]);
+		    }
+		  }
                 }
               }
             }
@@ -303,7 +310,7 @@
 /**
  * Retrieve related taxonomy terms.
  */
-function _relatedlinks_get_terms($tids, $nid) {
+function _relatedlinks_get_terms($tids, $nid, $node_type) {
   // The following query is likely to prove expensive when the numbers involved
   // are large. pgSQL compliant?
   // taxonmy_select_nodes returns 'x' results where x is determined by the
@@ -312,8 +319,10 @@
 
   $terms = array();
   while ($node = db_fetch_array($result)) {
+    // check the node type
+    $node2 = db_fetch_array(db_query('SELECT type FROM {node} WHERE nid = %d', $node['nid']));
     // Exclude the current nid.
-    if ($node['nid'] != $nid) {
+    if ($node['nid'] != $nid && $node_type == $node2['type']) {
       $terms[] = l($node['title'], 'node/'. $node['nid']);
     }
   }
