I now know how to create, using a php snippet

1. a list of latest comments http://drupal.org/node/56235
2. a list of latest comments ONLY for published nodes http://drupal.org/node/208082

Can someone show me a php snippet where I call for list of comments on published nodes ( as in http://drupal.org/node/208082), but also I can select comments only on nodes of a particular vocabulary or category(so possibly 2 different snippets).

nevets really helped me before, but if anyone has any ideas I'd love to see them.

thanks,

art

newmediarights.org

Comments

nevets’s picture

To limit by vocabulary (note you need to change $vid)

<?php
$max = 10;
$vid = 1;   // Change this to your vocabulary id
$query = 'SELECT DISTINCT(c.cid),c.nid,c.subject FROM {comments} c JOIN {node} n USING(nid) JOIN {term_node} tn USING(nid)  JOIN {term_data} td USING(tid) WHERE n.status = 1 AND td.vid = %d order by timestamp desc ';
$result = db_query_range($query, $vid, 0, $max);
$items = array ();
while ($comment = db_fetch_object($result)) {
$items[] = l($comment->subject, "node/$comment->nid", NULL, NULL, "comment-$comment->cid");
}
if (count($items)) {
return theme('item_list', $items);
}
?>

To limit by taxonomy(vocabulary) term (note you need to change $tid)

<?php
$max = 10;
$tid = 1;    // Change this to your taxonomy term id
$query = 'SELECT DISTINCT(c.cid),c.nid,c.subject FROM {comments} c JOIN {node} n USING(nid) JOIN {term_node} tn USING(nid) WHERE n.status = 1 AND tn,tid = %d order by timestamp desc ';
$result = db_query_range($query, $tid, 0, $max);
$items = array ();
while ($comment = db_fetch_object($result)) {
$items[] = l($comment->subject, "node/$comment->nid", NULL, NULL, "comment-$comment->cid");
}
if (count($items)) {
return theme('item_list', $items);
}
?>