Recent Comments

$NUMBER_OF_COMMENTS = 10;

//mysql query
$comments = db_query("SELECT c.* from {comments} c INNER JOIN {node} n ON n.nid = c.nid WHERE n.type = 'blog' ORDER BY timestamp DESC LIMIT $NUMBER_OF_COMMENTS");

$zebra = 'odd';

//format the comments
while($comment = db_fetch_object($comments)) {
$node = node_load($comment->nid);
$output .= ‘

‘;
$output .= ‘
‘;

if ($comment->homepage) {
$author = l($comment->name, $comment->homepage);
}
else {
$author = $comment->name;
}

$output .= ‘

‘ . check_markup($comment->comment, $comment->format, FALSE) . ‘

‘;
$output .= ‘

‘ . $author . ‘ | ‘ . l(format_date($comment->timestamp), ‘node/’ . $node->nid, NULL, NULL, ‘comment-’ . $comment->cid) . ‘ | ‘ . l($node->title, “node/$node->nid”) . ‘

‘;
$output .= ‘

‘;

if ($zebra = ‘odd’) {
$zebra = ‘even’;
}
else {
$zebra = ‘odd’;
}

}

print $output;

?>

No related posts.


Leave a Reply