Forum
Welcome, Guest
Please Login to access forum.
Include comments count into featured articles (1 viewing) 
Go to bottom
TOPIC: Include comments count into featured articles
#8092
John Dagelmore
Admin
Posts: 3722
User Offline
Include comments count into featured articles Karma: 79  
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>';
 
Logged Logged  
  The administrator has disabled public write access.
Go to top