Hi, thank you for your work, but the new 2.2 version has changed some references into the code and now it's difficult to integrate jcomment, would anyone be so kind to update instructions in order to make our favourite comment component workwith k2?
Well im suprised that i made my way into it

. But here it is my implementation of the hack for k2 v2.2 (just an update of the line numbers). Many thanks to all for this (the hack)
1. Open components/com_k2/templates/item.php and remove next code from line 494 up to 571:
<?php if(
$this->item->params->get('itemComments') && !JRequest::getInt('print') && ($this->item->params->get('comments') == '1' || ($this->item->params->get('comments') == '2'))):?>
<!-- Item comments -->
<a name="itemCommentsAnchor" id="itemCommentsAnchor"></a>
<div class="itemComments">
<?php if($this->item->params->get('commentsFormPosition')=='above' && $this->item->params->get('itemComments') && !JRequest::getInt('print') && ($this->item->params->get('comments') == '1' || ($this->item->params->get('comments') == '2' && K2HelperPermissions::canAddComment($this->item->catid)))): ?>
<!-- Item comments form -->
<div class="itemCommentsForm">
<?php echo $this->loadTemplate('comments_form'); ?>
</div>
<?php endif; ?>
<?php if($this->item->numOfComments>0 && $this->item->params->get('itemComments') && !JRequest::getInt('print') && ($this->item->params->get('comments') == '1' || ($this->item->params->get('comments') == '2'))): ?>
<!-- Item user comments -->
<h3 class="itemCommentsCounter">
<span><?php echo $this->item->numOfComments; ?></span> <?php echo ($this->item->numOfComments>1) ? JText::_('comments') : JText::_('comment'); ?>
</h3>
<ul class="itemCommentsList">
<?php foreach ($this->item->comments as $key=>$comment): ?>
<li class="<?php echo ($key%2) ? "odd" : "even"; ?>">
<span class="commentLink">
<a href="<?php echo $this->item->link; ?>#comment<?php echo $comment->id; ?>" name="comment<?php echo $comment->id; ?>" id="comment<?php echo $comment->id; ?>">
<?php echo JText::_('Comment Link'); ?>
</a>
</span>
<?php if($comment->userImage):?>
<img src="<?php echo $comment->userImage; ?>" alt="<?php echo $comment->userName; ?>" width="<?php echo $this->item->params->get('commenterImgWidth'); ?>" />
<?php endif; ?>
<span class="commentDate">
<?php echo JHTML::_('date', $comment->commentDate, JText::_('DATE_FORMAT_LC2')); ?>
</span>
<span class="commentAuthorName">
<?php echo JText::_("posted by"); ?>
<?php if(!empty($comment->userLink)): ?>
<a href="<?php echo $comment->userLink; ?>" title="<?php echo $comment->userName; ?>">
<?php echo $comment->userName; ?>
</a>
<?php else: ?>
<?php echo $comment->userName; ?>
<?php endif; ?>
</span>
<p><?php echo $comment->commentText; ?></p>
<span class="commentAuthorEmail">
<?php echo JHTML::_('Email.cloak', $comment->commentEmail, 0); ?>
</span>
<br class="clr" />
</li>
<?php endforeach; ?>
</ul>
<div class="itemCommentsPagination">
<?php echo $this->pagination->getPagesLinks(); ?>
<div class="clr"></div>
</div>
<?php endif; ?>
<?php if($this->item->params->get('commentsFormPosition')=='below' && $this->item->params->get('itemComments') && !JRequest::getInt('print') && ($this->item->params->get('comments') == '1' || ($this->item->params->get('comments') == '2' && K2HelperPermissions::canAddComment($this->item->catid)))): ?>
<!-- Item comments form -->
<div class="itemCommentsForm">
<?php echo $this->loadTemplate('comments_form'); ?>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
And add next code instead of previous one:
<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
$comments = JPATH_BASE . DS . 'components' . DS . 'com_jcomments' . DS . 'jcomments.php';
if (file_exists($comments)) {
require_once($comments);
?>
<a name="itemCommentsAnchor" id="itemCommentsAnchor"></a>
<?php
echo JComments::showComments($this->item->id, 'com_k2', $this->item->title);
}
?>
2. Open components/com_k2/models/item.php (line 826 up to 834) file and replace:
function countItemComments($itemID){
$db = & JFactory::getDBO ();
$query="SELECT COUNT(*) FROM #__k2_comments WHERE published=1 AND itemID={$itemID}";
$db->setQuery($query);
$result = $db->loadResult();
return $result;
}
at:
function countItemComments($itemID){
$comments = JPATH_BASE . DS . 'components' . DS . 'com_jcomments' . DS . 'jcomments.php';
if (file_exists($comments)) {
require_once($comments);
return JComments::getCommentsCount($itemID, 'com_k2');
}
return 0;
}
Works for me!
