Forum
Welcome, Guest
Please Login to access forum.
Re:Include comments count into featured articles (1 viewing) 
Go to bottom
TOPIC: Re:Include comments count into featured articles
#8143
John Dagelmore
Admin
Posts: 3882
User Online Now
Re:Include comments count into featured articles Karma: 84  
The code for Joomla 4/5/6 to allow to post comments only if permissions are allowed is the following:

Code:

require_once (JPATH_ROOT . '/components/com_jcomment/classes/config.php'); 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/classes/security.php'); require_once (JPATH_ROOT . '/components/com_jcomment/classes/acl.php'); require_once (JPATH_ROOT . '/components/com_jcomment/models/jcomment.php'); $acl = JCommentFactory::getACL(); if($acl->canComment) { $count = 0; $options = array (); $options ['object_id'] = ( int ) $this->item->id; $options ['object_group'] = 'com_content'; $options ['published'] = 1; Factory::getApplication ()->input->set ( 'view', 'article' ); $count = JCommentModel::getCommentsCount ( $options ); Factory::getApplication ()->input->set ( 'view', 'featured' ); $link = Route::_ ( Joomla\Component\Content\Site\Helper\RouteHelper::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