UPDATES EasyBlog 6.0.11 Released! Update to the latest version now!

Helpdesk

Your Time
Our Time
Response Time
24 — 48 hours
We strive to provide the fastest ever response possible. However, we are not super beings.

Allow at least 24 — 48 hours
  Support is online
Our support specialists is available now. We will attend to you as soon as we can.
  Support is online

How to show number of comments after article title?

Niccolo Angeli · ·
11:05 PM Saturday, 14 July 2018
Normal
Hello,
I have a custom article template and I want to display the number of comments and the total rating right after the article title.

I have added this code in my custom template here /test/templates/rt_galatea/html/com_content/article


<!-- Render Komento rating on single article page -->
<?php
// call Komento comment model
$commentsModel = KT::model('Comments');

// Retrieve total rating for this particular article post (single article page)
$ratings = $commentsModel->getOverallRatings('com_content', $this->item->id);

if ($ratings) {
$totalRating = $ratings->value;
$totalRatingCount = $ratings->total;
}
?>



<div id="kt">
<h3 class="kt-title-bar__title">
<?php echo JText::_('COM_KOMENTO_COMMENTS'); ?> (<span class="commentCounter" data-kt-counter><?php echo $commentCount; ?></span>;)
</h3>
<div class="kt-ratings-overview" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
<div class="kt-ratings-stars" data-kt-ratings-overall data-score="<?php echo $totalRating / 2; ?>"></div>

<span class="kt-ratings-title"><?php echo JText::sprintf('COM_KOMENTO_RATING_OVERVIEW_TOTAL', $totalRating / 2, 5, $totalRatingCount);?></span>

<meta itemprop="ratingValue" content="<?php echo $totalRating / 2;?>" />
<meta itemprop="reviewCount" content="<?php echo $totalRatingCount;?>" />
<meta itemprop="bestRating" content="5" />
<meta itemprop="worstRating" content="0" />
</div>
</div>
<!-- Render Komento rating on single article page - end -->


but this part of the code is not working

<h3 class="kt-title-bar__title">
<?php echo JText::_('COM_KOMENTO_COMMENTS'); ?> (<span class="commentCounter" data-kt-counter><?php echo $commentCount; ?></span>;)
</h3>

it should show "comments (0)" when there are no comments, but it just shows "comments ()"
I inserted a test comment and it still shows "comments ()"

I understand that the code I insrted is probably not retrieving the total number of comments, in fact
the same code above the normal komento comment form is working fine and shows "comments (0)" or "comments (1)"
(see screenshot komento_2)

could you teel me how to fix this?
thank you
The replies under this section are restricted to logged in users or users with an active subscription with us