[spoiler title=Инструкция по интеграции JComments 2.2 с компонентом K2 v2.2+ (плагин)]
Скачайте, установите и опубликуйте плагин
K2 JComments в менеджере расширений Joomla:
K2 JComments 1.2[/spoiler]
[spoiler title=Инструкция по интеграции JComments 2.1 с компонентом K2 v2.1 (устаревшие версии, требует модификации кода компонента)]
Инструкция по интеграции JComments 2.1 с компонентом
K2 v2.1 (
build 20090909):
1. Откройте файл
components/com_k2/templates/item.php и удалите строки с 486 по 560:
<?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; ?>
И замените на следующий код:
<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
if ($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)))) { ?>
$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. Откройте файл
components/com_k2/models/item.php и найдите функцию (строки 777 по 785):
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;
}
на следующую функцию:
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;
}
3. Если у вас установлена старая версия компонента JComments (2.0), то тогда скачайте приложенный к данному посту файл, разархивируйте его и положите файл com_k2.plugin.php в папку
/components/com_jcomments/plugins/ . Если вы используете JComments 2.1, то данный шаг можете пропустить.[/spoiler]
Приятного использования JComments с K2!
[вложение удалено Администратором]