| |
I was trying to get jComment to show comment count, before entering the article itself. After alot of search i found couple of solutions i managed to combine to get jComment Working so that people can see comment status on the articles in K2. Ofcourse you need to have K2 Component, jComment Component and Plugin Installed. Make sure that the plugin is activated.
1. Enter you FTP
2. Edit /joomla_root/components/com_k2/models/item.php
3. On row about 851 you will find the line
function countItemComments($itemID){
$db = & JFactory::getDBO ();
$query="SELECT COUNT(*) FROM --#__k2_comments WHERE published=1 AND itemID=".(int)$itemID;
$db->setQuery($query);
$result = $db->loadResult();
return $result;
}
4. Change it with the code below:
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;
}
5. Save
6. Edit the file /joomla_root/components/com_k2/templates/default/item.php
7. Find the code on row about 521 to 594 that looks like the code below:
<!-- Item comments -->
<a name="itemCommentsAnchor" id="itemCommentsAnchor"></a>
<div class="itemComments">
<!-- Item comments form -->
<div class="itemCommentsForm">
<!-- Item user comments -->
<h3 class="itemCommentsCounter">
<span>
</h3>
<ul class="itemCommentsList">
<li class="<?php echo ($key%2) ? "odd" : "even"; echo (!$this->item->created_by_alias && $comment->userID==$this->item->created_by) ? " authorResponse" : ""; ?>">
<span class="commentLink">
<a href="/item->link; ?>#commentid; ?>" name="commentid; ?>" id="commentid; ?>">
<img src="/userImage; ?>" alt="userName; ?>" width="item->params->get('commenterImgWidth'); ?>" />
<span class="commentDate">
</span>
<span class="commentAuthorName">
<?php echo JText::_("posted by"); ?>
<a href="/userLink; ?>" title="userName; ?>" target="_blank" rel="nofollow">
</p>
<div class="clr"></div>
</li>
</ul>
<div class="itemCommentsPagination">
<div class="clr"></div>
</div>
<!-- Item comments form -->
<div class="itemCommentsForm">
<?php echo $this->loadTemplate('comments_form'); ?>
</div>
<?php endif; ?>
<?php $user = &JFactory::getUser(); if ($this->item->params->get('comments') == '2' && $user->guest):?>
<div><?php echo JText::_('Login to post comments');?></div>
<?php endif; ?>
</div>
<?php endif; ?>
8. And Change it with this code:
<a name="itemCommentsAnchor" id="itemCommentsAnchor"></a> <?php echo JComments::showComments($this->item->id, 'com_k2', $this->item->title); } ?>
9. Save and your done. You should now see the comment counter on your K2 Site.
Ayande
Website: www.ayande.se E-mail: This e-mail address is being protected from spambots. You need JavaScript enabled to view itContact Details
-
CityStockholm
-
CountrySweden






Do not promote sites here.