Drupal 4.7 bietet einen Block, in dem Links zu den neusten Kommentaren angezeigt werden. In dieser Modifikation wird anstelle des Kommentartitles, der Titel des zugehörigen Inhalts angezeigt.
<?php
global $user;
$sql = 'SELECT u.uid, c.name, c.nid, c.subject, c.cid, c.timestamp, n.title
FROM {comments} c
INNER JOIN {node} n ON n.nid = c.nid
INNER JOIN {users} u ON c.uid = u.uid
WHERE n.status = 1 AND c.status = %d ORDER BY c.timestamp DESC';
$result = db_query_range(db_rewrite_sql($sql, 'c'), COMMENT_PUBLISHED, 0, 5);
$items = array();
while ($comment = db_fetch_object($result)) {
$name = $comment->name;
if (strlen($name) > 15) {
$name = substr($name,0,14);
}
if ($comment->uid > 0 && user_access('access user profiles', $user)) {
$author = l($name, 'user/'. $comment->uid);
} else {
$author = $name;
}
$items[] = l($comment->title, 'node/'. $comment->nid,
NULL, NULL, 'comment-'. $comment->cid) .' '. t('by') .' '. $author .' '.
t('%time ago', array('%time' => format_interval(time() - $comment->timestamp)));
}
return theme('item_list', $items);
?>
Post new comment