By ahneill on
I know how to create a simple list of comments, such as here. http://drupal.org/node/56235
However, this shows ALL comments, even if they are attached to unpublished nodes. Can someone alter this code to only list comments on published nodes?
thanks
$max = 10;
$query = 'SELECT nid,cid,subject FROM {comments} order by timestamp desc ';
$result = db_query_range($query, 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);
}
art
Comments
This should limit the comments to published nodes
Change the query to