By Niccolo Angeli on Thursday, 07 June 2018
Posted in Technical Issues
Replies 1
Likes 0
Views 634
Votes 0
Hello,
could you suggest a snippet of php code to insert the total number of ratings (with stars) in other places on the page (same page where Komento form is being loaded).
I want to insert this near the title of joomla articles and Hikashop products.

Thank you
For the Joomla single article page, you can try apply this following code into this PHP file.
JoomlaFolder/components/com_content/views/article/tmpl/default.php
You can take a look of my attached file where i put that following code into that PHP file.
[gist type="php"]
<?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">
<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>
[/gist]

But I am not familiar with Hikashop code so I do not know which PHP file render that single product page, perhaps you can consult with Hikashop developer regarding this.
·
Thursday, 07 June 2018 10:23
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post