Insert a quicklist of recent forum topic titles and links
Last modified: October 6, 2006 - 01:36
PLEASE NOTE! The following snippets are user submitted. Use at your own risk! For users who have setup drupal using an alternate database to the default (MYSQL), please note that the snippets may contain some database queries specific to MYSQL.
<?php
/**
* Creates a quicklist of recent forum topic titles and a link to their
* node.
*
* works and tested with 4.6
* does not work with 4.5
*
* To increase the length of the list, change $listlength
*
*/
$listlength="10";
$sql = "SELECT n.nid, n.title, l.last_comment_timestamp, l.comment_count FROM {node} n INNER JOIN {node_comment_statistics} l ON n.nid = l.nid WHERE n.status = 1 AND n.type='forum' ORDER BY l.last_comment_timestamp DESC";
$sql = db_rewrite_sql($sql);
$content = node_title_list(db_query_range($sql, 0, $listlength), t('Active forum topics:'));
if ($content) {
$content .= '<div class="more-link">'. l(t('more'), 'forum', array('title' => t('Read the latest forum topics.'))) .'</div>';
}
print $content;
?>