Index: taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy.module,v
retrieving revision 1.139
diff -u -r1.139 taxonomy.module
--- taxonomy.module	21 Aug 2004 06:42:37 -0000	1.139
+++ taxonomy.module	30 Aug 2004 03:58:26 -0000
@@ -760,7 +760,7 @@
  * @return
  *   A resource identifier pointing to the query results.
  */
-function taxonomy_select_nodes($tids = array(), $operator = 'or', $depth = 0, $pager = TRUE) {
+function taxonomy_select_nodes($tids = array(), $operator = 'or', $depth = 0, $pager = TRUE, $type) {
   if (count($tids) > 0) {
     // For each term ID, generate an array of descendant term IDs to the right depth.
     $descendant_tids = array();
@@ -775,8 +775,21 @@
 
     if ($operator == 'or') {
       $str_tids = implode(',', call_user_func_array('array_merge', $descendant_tids));
-      $sql = 'SELECT DISTINCT(n.nid) FROM {node} n '. node_access_join_sql() .' INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN ('. $str_tids .') AND n.status = 1 AND '. node_access_where_sql() .' ORDER BY n.sticky DESC, n.created DESC';
+      $sql = 'SELECT DISTINCT(n.nid) FROM {node} n '. node_access_join_sql() .' INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN ('. $str_tids .') AND n.status = 1 AND '. node_access_where_sql();
+      if ($type == 'all'){
+      $sql .= '';
+      }
+      else{
+      $sql .= " AND n.type = '". $type ."'";
+      }
+      $sql .= ' ORDER BY n.sticky DESC, n.created DESC';
       $sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n '. node_access_join_sql() .' INNER JOIN {term_node} tn ON n.nid = tn.nid WHERE tn.tid IN ('. $str_tids .') AND n.status = 1 AND '. node_access_where_sql();
+      if ($type == 'all'){
+      $sql_count .= '';
+      }
+      else{
+      $sql_count .= " AND n.type = '". $type ."'";
+      }
     }
     else {
       $joins = '';
@@ -785,6 +798,12 @@
         $joins .= ' INNER JOIN {term_node} tn'. $index .' ON n.nid = tn'. $index .'.nid';
         $wheres .= ' AND tn'. $index .'.tid IN ('. implode(',', $tids) .')';
       }
+      if ($type == 'all'){
+      $wheres .= '';
+      }
+      else{
+      $wheres .= " AND n.type = '". $type ."'";
+      }
       $sql = 'SELECT DISTINCT(n.nid) FROM {node} n '. node_access_join_sql() . $joins .' WHERE n.status = 1 AND '. node_access_where_sql() . $wheres .' ORDER BY n.sticky DESC, n.created DESC';
       $sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n '. node_access_join_sql() . $joins .' WHERE n.status = 1 AND '. node_access_where_sql() . $wheres;
     }
@@ -806,10 +825,15 @@
 */
 function taxonomy_render_nodes($result) {
 
-  while ($node = db_fetch_object($result)) {
-    $output .= node_view(node_load(array('nid' => $node->nid)), 1);
+  if(db_num_rows($result) > 0) {
+    while ($node = db_fetch_object($result)) {
+      $output .= node_view(node_load(array('nid' => $node->nid)), 1);
+    }
+    $output .= theme('pager', NULL, variable_get('default_nodes_main', 10), 0);
+  }
+  else {
+    $output .= t('There are currently no posts in this category.');
   }
-  $output .= theme('pager', NULL, variable_get('default_nodes_main', 10), 0);
   return $output;
 }
 
@@ -833,7 +857,7 @@
 /**
  * Menu callback; displays all nodes associated with a term.
  */
-function taxonomy_term_page($str_tids = '', $depth = 0, $op = 'page') {
+function taxonomy_term_page($str_tids = '', $depth = 0, $op = 'page', $type = 'all') {
   if (preg_match('/^([0-9]+[+ ])+[0-9]+$/', $str_tids)) {
     $operator = 'or';
     // The '+' character in a query string may be parsed as ' '.
@@ -869,7 +893,7 @@
 
       drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS - '. $title .'" href="'. url('taxonomy/term/'. $str_tids .'/'. $depth .'/feed') .'" />');
 
-      $output = taxonomy_render_nodes(taxonomy_select_nodes($tids, $operator, $depth, TRUE));
+      $output = taxonomy_render_nodes(taxonomy_select_nodes($tids, $operator, $depth, TRUE, $type));
       print theme('page', $output, $title);
       break;
 
@@ -879,7 +903,7 @@
       $channel['title'] = variable_get('site_name', 'drupal') .' - '. $title;
       $channel['description'] = $term->description;
 
-      $result = taxonomy_select_nodes($tids, $operator, $depth, FALSE);
+      $result = taxonomy_select_nodes($tids, $operator, $depth, FALSE, $type);
       node_feed($result, $channel);
       break;
 
