By calebgilbert on
I have been trying to modify my "Recent Comments" block all day to show the 1) the title of the comment and 2) the author of the comment. I've gotten really close to having it work out ok, but there is a weird glitch - about 20% of the comments are showing as having no author. The weirdest part is that there is no pattern to what causes it to do this (e.g., it's not just certain users who are getting bypassed nor just specific nodes). At this point it appears totally random. While I'm sure it's not, I also am out of ideas. Below is the current code I have in the comment.module - any tips anyone has would be really great! (Drupal v. 4.5.2, btw)
function comment_block($op = 'list', $delta = 0) {
if ($op == 'list') {
$blocks[0]['info'] = t('Recent comments');
return $blocks;
}
else if (user_access('access comments')) {
$result = db_query_range('SELECT * FROM {comments} WHERE status = 0 ORDER BY timestamp DESC', 0, 20);
$items = array();
while ($comment = db_fetch_object($result)) {
$items[] = '<b>'.l($comment->subject, 'node/'. $comment->nid, NULL, NULL, "comment-$comment->cid").'</b>'.'<br />'.' by '.$comment->name;
}
$block['subject'] = t('Recent comments');
$block['content'] = theme('item_list', $items);
return $block;
}
}
Comments
interested in the same thing
Can't offer any help off the top of my head, unfortunately. I just want to watch this thread and check back on it after I get my head above water from the current job I'm working on. Too bad the main drupal site doesn't have a better way to watch a thread than posting a "me too" comment.
Try this
Finally worked it out myself:
Change the number of comments show in the block by changing the value of $nlimit. If you want to see what it looks like working, check out the right hand links at the site below.
Political Physics
Please note that this is a block
...and not in the comment module itself (though one could put it there if they really wanted to).
Political Physics
Not sure if this is still
Not sure if this is still relevant for you, but here's a patch for 5.1 that adds the comment author to the recent comments block: http://drupal.org/node/124299