Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

JoomlaTune Support Forum    JComments component    Integration with third-party extensions    K2 JComments    Topic: K2 Comment Counter
Pages: [1]   Go Down
  Print  
Author Topic: K2 Comment Counter  (Read 5879 times)
0 Members and 1 Guest are viewing this topic.
giribabuvpy
Newbie
*

Karma: 0
Offline Offline

Posts: 3


« on: June 04, 2010, 13:23:27 »

JComment working good in my K2 Component but I not able to see the Comment Count and Be the First comment any one can help me, where I have to change the code or any other solutions? Sad

Regards,
Hemanth.
Logged
smart
Administrator
Hero Member
*****

Karma: 160
Offline Offline

Gender: Male
Posts: 2559



WWW
« Reply #1 on: June 04, 2010, 13:38:59 »

What integration type do you use? Do you've changed K2 template code or just installed K2 JComments plugin?
Logged

If you use JComments, please post a rating and a review at the Joomla! Extensions Directory
giribabuvpy
Newbie
*

Karma: 0
Offline Offline

Posts: 3


« Reply #2 on: June 04, 2010, 14:40:38 »

Thanks,

I got solution

Code:
<?php 
$dbc=&JFactory::getDBO();
$sql="select count(*) from #__jcomments where object_id='".$this->item->id."';";
$run=$dbc->setQuery($sql);
$count $dbc->loadResult();
//echo $sql;

if(isset($count) && $count<1) {
echo <a href="<?php echo $this->item->link; ?>
#itemCommentsAnchor">Be the first to Comment </a>';
} else {
echo '<a href="<?php echo $this->item->link?>#itemCommentsAnchor">$count &nbsp;&nbsp;Comment(s)</a>';
}
?>
Logged
smart
Administrator
Hero Member
*****

Karma: 160
Offline Offline

Gender: Male
Posts: 2559



WWW
« Reply #3 on: June 04, 2010, 14:42:36 »

Try to use K2 JComments plugin (it was released yesterday and available for downloads from our site). It allows to use JComments in K2 2.2 and higher without any code hacks.
Logged

If you use JComments, please post a rating and a review at the Joomla! Extensions Directory
giribabuvpy
Newbie
*

Karma: 0
Offline Offline

Posts: 3


« Reply #4 on: June 04, 2010, 14:47:39 »

Sorry, Syntax error previous code,

Code:
<?php 
$dbc=&JFactory::getDBO();
$sql="select count(*) from #__jcomments where object_id='".$this->item->id."';";
$run=$dbc->setQuery($sql);
$count $dbc->loadResult();
//echo $sql;

if(isset($count) && $count<1) {
echo '<a href='.$this->item->link.'#itemCommentsAnchor">Be the first to Comment </a>';
} else {
echo '<a href='.$this->item->link.'#itemCommentsAnchor">'.$count.'&nbsp;&nbsp;Comment(s)</a>';
}
?>

This is what I am expecting.
Logged
smart
Administrator
Hero Member
*****

Karma: 160
Offline Offline

Gender: Male
Posts: 2559



WWW
« Reply #5 on: June 04, 2010, 14:50:49 »

Try to use plugin or change your code with:

Code: (php)
<?php 
$dbc=&JFactory::getDBO();
$sql="select count(*) from #__jcomments where object_group='com_k2' and object_id='".$this->item->id."';";
$dbc->setQuery($sql);
$count $dbc->loadResult();

if(!$count) {
echo '<a href="' $this->item->link '#itemCommentsAnchor">Be the first to Comment </a>';
} else {
echo '<a href="' $this->item->link '#itemCommentsAnchor">' $count '&nbsp;&nbsp;Comment(s)</a>';
}
?>
Logged

If you use JComments, please post a rating and a review at the Joomla! Extensions Directory
ayande
Newbie
*

Karma: 0
Offline Offline

Posts: 1


« Reply #6 on: September 21, 2010, 09:45:58 »

I don't understand were to put in the code you posted above?! I tried to install the plugin but the comment counter wont work, although everything else does work.
Logged
Masoud
Newbie
*

Karma: -1
Offline Offline

Posts: 24



« Reply #7 on: October 28, 2010, 11:07:17 »

where we should put the code?

I have K2 Jcomment plugins but the comment counter does not work in category view , latest view, however it works properly in item view
Logged

----------------------
www.zoomit.ir
marcodeluca
Newbie
*

Karma: 0
Offline Offline

Posts: 5


« Reply #8 on: February 01, 2011, 04:04:13 »

Has there been a solution for this? The K2 / jcomments plugin works fine for the main component, but it does not work for modules like K2_content... it also does not work with 3rd party modules, like Rockettheme modules that integrate with K2.
Logged
rookpl
Newbie
*

Karma: 0
Offline Offline

Posts: 5


« Reply #9 on: February 03, 2011, 22:35:52 »

Try to use plugin or change your code with:

Code: (php)
<?php 
$dbc=&JFactory::getDBO();
$sql="select count(*) from #__jcomments where object_group='com_k2' and object_id='".$this->item->id."';";
$dbc->setQuery($sql);
$count $dbc->loadResult();

if(!$count) {
echo '<a href="' $this->item->link '#itemCommentsAnchor">Be the first to Comment </a>';
} else {
echo '<a href="' $this->item->link '#itemCommentsAnchor">' $count '&nbsp;&nbsp;Comment(s)</a>';
}
?>

Thank you for hat code. I tried many solutions, and only with that code comments counters are visible on my main page. It adds one additional query per article.

k2 plugin works, but counter is visible only in item view (after "read more" click), in category item list / front page it works only with that code.
Logged
BBC
Full Member
***

Karma: 4
Offline Offline

Posts: 197



« Reply #10 on: February 04, 2011, 00:23:40 »

For counters in K2 you need to activate all comments options in K2. Parameters, Categories, Items.
Otherways it wont count, doesn´t matter if you don´t use native K2 comments.
Logged
senseraw
Guest
« Reply #11 on: May 27, 2011, 16:49:40 »

smart, скажи пожалуйста какой код нужен, чтобы счётчик правильно работал для файлов generic.php и user.php


код выше работает корректно только для category_item.php
Logged
rygrath
Newbie
*

Karma: 0
Offline Offline

Posts: 1


Email
« Reply #12 on: January 02, 2012, 09:31:06 »

Try to use plugin or change your code with:

Code: (php)
<?php 
$dbc=&JFactory::getDBO();
$sql="select count(*) from #__jcomments where object_group='com_k2' and object_id='".$this->item->id."';";
$dbc->setQuery($sql);
$count $dbc->loadResult();

if(!$count) {
echo '<a href="' $this->item->link '#itemCommentsAnchor">Be the first to Comment </a>';
} else {
echo '<a href="' $this->item->link '#itemCommentsAnchor">' $count '&nbsp;&nbsp;Comment(s)</a>';
}
?>

Thank you for hat code. I tried many solutions, and only with that code comments counters are visible on my main page. It adds one additional query per article.

k2 plugin works, but counter is visible only in item view (after "read more" click), in category item list / front page it works only with that code.

Does anyone know where this code is inserted? I have the same issue with my site. On the frontpage / category item list, all comment links read as "Be the first to comment" regardless if there are comments or not. However, if I go into one specific K2 category, I can see the comment counter working properly for all items listed.

The Frontpage setup is using the K2 category listing option with multiple categories selected. I've been wracking my head trying to fix this and I just can't seem to find the exact place where it's broken.

I would greatly appreciate any assistance to this as everything else with Jcomments is working wonderfully. This is just the last little issue I have that I'd like to fix.

Thank you for any responses!

Edit: I should have put in some details. Running Joomla 1.5.25. Jcomments 2.2.0.2. K2 Jcomments plugin 1.2. Using the Yootheme Vanilla template.
« Last Edit: January 03, 2012, 05:31:10 by rygrath » Logged
poiu98
Newbie
*

Karma: 0
Offline Offline

Gender: Male
Posts: 2


angello87@gaaa.hu
WWW Email
« Reply #13 on: January 02, 2012, 19:20:41 »

What integration type do you use? Do you've changed K2 template code or just installed K2 JComments plugin?



Thanks a lot ... this is my question to !
Logged

am i the only one who : acai
Pages: [1]   Go Up
  Print  
JoomlaTune Support Forum    JComments component    Integration with third-party extensions    K2 JComments    Topic: K2 Comment Counter
 
Jump to: