the only thing I can find on adding the ability to display the number of comments in the news module is not working. Post look to be from 2005 so I'm sure some of the base code has changed.
the count seems to be working (i can display it in the footer of the detail page of the news article) but it will not assign to a label so that I can call it on the main news page.
Can someone look at this code and see if I messed something up
// Query for comments
$query_comments = $database->query("SELECT title,comment,commented_when,commented_by FROM ".TABLE_PREFIX."mod_news_comments WHERE post_id = '".POST_ID."' ORDER BY commented_when ASC");
$comments_count=$query_comments->numRows();
if($query_comments->numRows() > 0) {
while($comment = $query_comments->fetchRow()) {
// Display Comments without slashes, but with new-line characters
$comment['comment'] = nl2br(($comment['comment']));
$comment['title'] = ($comment['title']);
// Print comments loop
$commented_date = gmdate(DATE_FORMAT, $comment['commented_when']+TIMEZONE);
$commented_time = gmdate(TIME_FORMAT, $comment['commented_when']+TIMEZONE);
$uid = $comment['commented_by'];
$vars = array('[TITLE]','[COMMENT]','[DATE]','[TIME]','[USER_ID]','[USERNAME]','[DISPLAY_NAME]', '[EMAIL]','[COMMENTS_COUNT]');
if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '') {
$values = array(($comment['title']), ($comment['comment']), $commented_date, $commented_time, $uid, ($users[$uid]['username']), ($users[$uid]['display_name']), ($users[$uid]['email']), $comments_count);
} else {
$values = array(($comment['title']), ($comment['comment']), $commented_date, $commented_time, '0', strtolower($TEXT['UNKNOWN']), $TEXT['UNKNOWN'], '', $comments_count);
}
echo str_replace($vars, $values, $setting_comments_loop);
}
in the NEWS settings I'm trying to call the number with [COMMENTS_COUNT]
seems like I've just overlooked something but I can't see it right now
thanks