By ZeRa on Thursday, 21 May 2020
Posted in General Issues
Likes 0
Views 861
Votes 0
Hello!
How do I place a comment counter on the Virtuemar product page in the comments tab, and on the category page? Thanks!
Currently I am not sure whether possible to achieve this or not, if VirtueMart extension has allow 3rd party developer to override the comment count using event trigger, then it would be good.

Perhaps for me you can send us your current VirtueMart extension installer so I can better have a check?

Also can you guide us how to setup to show product category and single product page?
·
Friday, 22 May 2020 11:06
·
0 Likes
·
0 Votes
·
0 Comments
·
The jcomment component has a counter running. Here is the code from them in the Virtuemart product productdetails:

<h2 id="jc"><?php echo JText::_ ('COM_VIRTUEMART_COMENTS'); ?><?php
$comments = JPATH_SITE . '/components/com_jcomments/jcomments.php';
if (file_exists($comments)) {
require_once($comments);
$options = array();
$options['object_id'] = $this->product->virtuemart_product_id;
$options['object_group'] = 'com_virtuemart';
$options['published'] = 1;
$count = JCommentsModel::getCommentsCount($options);
echo $count = (' ('. $count . ')') ;
} ?></h2>


Need a similar code from your Komento
·
Friday, 22 May 2020 19:34
·
0 Likes
·
0 Votes
·
0 Comments
·
Do you mean you have to apply this hack into Virtuemart? I guess if you want to insert your own set of hacks into Virtuemart, you could add a code like this:


<?php
require_once(JPATH_ROOT. '/administrator/components/com_komento/includes/komento.php');

$model = KT::model('Comments');
$count = $model->getCount('com_virtuemart', $this->product->virtuemart_product_id);
?>
(<?php echo $count;?>)
·
Saturday, 23 May 2020 00:43
·
0 Likes
·
0 Votes
·
0 Comments
·
Yay! YES! It works!
But only on the product page. It doesn't work on the product category page
Look, this code uses Jcomments on the category page, can it also be used for Komento?

<?php
$comments = JPATH_SITE . '/components/com_jcomments/jcomments.php';
if (file_exists($comments)) {
require_once($comments);
$options = array();
$options['object_id'] = $product->virtuemart_product_id;
$options['object_group'] = 'com_virtuemart';
$options['published'] = 1;
$count = JCommentsModel::getCommentsCount($options);
echo $count ? ('Comments: '. $count ) : 'Coment: 0';
}
?>

Thank you in advance! I'll drink vodka to Your health today!
·
Saturday, 23 May 2020 23:39
·
0 Likes
·
0 Votes
·
0 Comments
·
It's pretty identical as the code previously:


<?php
require_once(JPATH_ROOT. '/administrator/components/com_komento/includes/komento.php');

$model = KT::model('Comments');
$count = $model->getCount('com_virtuemart', $product->virtuemart_product_id);
?>
Comment (<?php echo $count;?>)
·
Sunday, 24 May 2020 00:04
·
0 Likes
·
0 Votes
·
0 Comments
·
Yes, everything works! Thank you for your help!
·
Sunday, 24 May 2020 20:13
·
0 Likes
·
0 Votes
·
0 Comments
·
You are most welcome
·
Sunday, 24 May 2020 21:00
·
0 Likes
·
0 Votes
·
0 Comments
·
View Full Post