It's possible to show the comments count for example in the 'featured' view using a template override for the file 'templates/mytemplate/html/com_content/featured/default_item.php' and placing the following code for Joomla 3 at the bottom:
Code: |
require_once(JPATH_ROOT . '/components/com_jcomment/classes/factory.php');
require_once(JPATH_ROOT . '/components/com_jcomment/classes/multilingual.php');
require_once(JPATH_ROOT . '/components/com_jcomment/models/jcomment.php');
$count = 0;
$options = array();
$options['object_id'] = (int)$this->item->id;
$options['object_group'] = 'com_content';
$options['published'] = 1;
JFactory::getApplication()->input->set ( 'view', 'article' );
$count = JCommentModel::getCommentsCount($options);
JFactory::getApplication()->input->set ( 'view', 'featured' );
$link = JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid, $this->item->language)) . '#addcomments';
echo '<a href="' . $link . '"><span class="icon-envelope"></span> ' . $count . ' comments - Add comment</a>';
|