Modification to disp nodes from many taxonomy terms or their children.
Last modified: July 15, 2006 - 05:46
<?php
/**
* This php snippet displays content of a specified type, with teasers,
* from certain taxonomy terms and their children.
* Sorted by date of creation, most recent first.
* Works with nodes of the flexinode type too.
* To change the length of the list, change $listlength.
* To change the taxomony term, change $taxo_id.
* To change the type of content listed, change the $content_type.
* Works by joining with the term_hierarchy table
* Tested with Drupal 4.7
*/
$listlength="5";
$taxo_id = "3,4,5"; /* comma seperated list */
$content_type = 'story';
$result1 = pager_query("SELECT n.nid, n.created FROM {node} n INNER JOIN ({term_node} tn LEFT JOIN {term_hierarchy} th ON tn.tid = th.tid) ON n.nid = tn.nid WHERE n.type = '$content_type' AND (tn.tid in ($taxo_id) OR th.parent in ($taxo_id)) AND n.status = 1 GROUP BY n.nid ORDER BY n.created DESC", $listlength);
while ($node = db_fetch_object($result1)) {
$output .= node_view(node_load(array('nid' => $node->nid)), 1);
}
print $output;
?>