Drupal Block Snippet: Meist kommentierte Beiträge

Mit folgendem Drupal Code-Schnipsel wird eine Liste der am häufigsten kommentierten Beiträge angezeigt. Das title-Attribut der Links enthält die Anzahl der Kommentare zum jeweiligen Inhalt, die bei Mouseover als Tooltip angezeigt werden.

<?php
$sql = 'SELECT n.nid, n.title, ncs.comment_count FROM {node} n
INNER JOIN {node_comment_statistics} ncs ON n.nid = ncs.nid
WHERE n.status = 1 ORDER BY ncs.comment_count DESC';
$result = db_query_range(db_rewrite_sql($sql), 0, 5);
if (db_num_rows($result)) {
  return node_title_list($result);
}
?>

No comments

Add your comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <p> <br>

More information about formatting options