Display a table of title & teaser for all nodes for Taxonomy term X

Last modified: December 26, 2006 - 18:44

PLEASE NOTE! The following snippets are user submitted. Use at your own risk! For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.

<?php
/**********************************************
* Displays a table of node title and node teaser
* for all nodes in the taxonomy term $taxo_id
*
* The title of the node is linked to the node
*
* snippet works with Drupal 4.6.6
*
*/

 
$taxo_id = 11;
 
$sql = "SELECT node.nid, node.title, node.teaser FROM node INNER JOIN term_node ON node.nid = term_node.nid WHERE term_node.tid = $taxo_id AND node.status = 1";
 
$result = db_query($sql);
while (
$node = db_fetch_object($result)) {
  
$output .= "<tr><td><a href=\"node/$node->nid\"> $node->title </a> </td>";
  
$output .= "<td>$node->teaser</td></tr>";
}

print
"<table border=1>";
print
$output;
print
"</table>";
?>

and for 4.7

<?php
/**********************************************
* Displays a table of node title and node teaser
* for all nodes in the taxonomy term $taxo_id
* The title of the node is linked to the node
*
* snippet works with Drupal 4.7
*
*/

$sql = "SELECT node_revisions.nid, node_revisions.title, node_revisions.teaser FROM node_revisions INNER JOIN (term_node INNER JOIN node ON node.nid = term_node.nid ) ON node_revisions.nid = term_node.nid WHERE (term_node.tid = 12 OR term_node.tid = 15 OR term_node.tid = 16) AND node.status = 1";
$result = db_query($sql);
while (
$node = db_fetch_object($result)) {
 
$output .= "<tr><td>&nbsp;<a href=\"node/$node->nid\"> $node->title </a>&nbsp;</td>";
 
$output .= "<td>&nbsp;$node->teaser&nbsp;</td></tr>";
}

print
"<table border=0><thead><tr><th>Procedure</th><th> Summary/Note</th> </tr></thead>";
print
$output;
print
"</table>";
?>

 
 

Drupal is a registered trademark of Dries Buytaert.