Hello,
I read this thread http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=16&t=11865&p=42187&hilit=count#p42187
To add comment count next to authour name(right below page title), I understand that i need to modify com_content/article/default.php
The code works if i put it in 'com_content/section/blog_item.php', but it always shows comments(0)in article page.
Can somebody help what i need to change or give me a hint? Thank you.
I read this thread http://www.chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=16&t=11865&p=42187&hilit=count#p42187
To add comment count next to authour name(right below page title), I understand that i need to modify com_content/article/default.php
The code works if i put it in 'com_content/section/blog_item.php', but it always shows comments(0)in article page.
Can somebody help what i need to change or give me a hint? Thank you.
// Get article ID
$articleid = $this->item->id;
// Get needed info from the database tables jos-chrono_comments and jos_content
$db =& JFactory::getDBO();
$query = "
SELECT count( `jos_chrono_comments`.`pageid` ) , `jos_content`.`id`
FROM `jos_chrono_comments` , `jos_content`
WHERE `jos_chrono_comments`.`pageid` = `jos_content`.`id`
AND `jos_content`.`id` = '".$articleid."'
GROUP BY `jos_content`.`id`;";
$db-> setQuery($query);
// count number of comments available and apply value to variable
$nrComments = count(`pageid`);
if ( $row = $db->loadAssoc($query) ) {
// if any result available in the query give nr comments (X)
echo "Comments (".$row["count( `jos_chrono_comments`.`pageid` )"].")";
} else {
// If there's no result in the query then give zero comments -->
echo "Comments (0)";
}
// Close link to nr of Comments