The code for Joomla 6/5/4 is the following one:
| 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/models/jcomment.php');
$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>';
|