这次我真的需要帮助 - Joomla 2.5 和最新的 K2。我正在使用默认的 K2 评论系统,我想为该页面上的每个评论者显示“描述”字段。到目前为止,我有这个代码:
$thisUserdata =& JFactory::getUser($comment->userID);
echo $thisUserdata->profile->description;
但这仅显示页面作者的描述。如果我使用其他帐户登录,只要我登录,它也会显示我自己的描述。
我正在做的所有编码都在 /components/com_k2/templates/default/item.php
注释的整个代码如下所示:
<?php if($this->item->numOfComments>0 && $this->item->params->get('itemComments') && ($this->item->params->get('comments') == '1' || ($this->item->params->get('comments') == '2'))): ?>
<!-- Item user comments -->
<ul>
<?php foreach ($this->item->comments as $key=>$comment): ?>
<li class="<?php echo ($key%2) ? "odd" : "even"; echo (!$this->item->created_by_alias && $comment->userID==$this->item->created_by) ? " author-comment" : ""; echo($comment->published) ? '':' unpublishedComment'; ?>">
<div class="avatar">
<?php if($comment->userImage): ?>
<a href="<?php echo JFilterOutput::cleanText($comment->userLink); ?>" target="_blank" rel="nofollow">
<img src="<?php echo $comment->userImage; ?>" alt="<?php echo JFilterOutput::cleanText($comment->userName); ?>" width="<?php echo $this->item->params->get('commenterImgWidth'); ?>" />
</a>
<?php endif; ?>
</div>
<div class="inner">
<div class="author">
<?php if(!empty($comment->userLink)): ?>
<a href="<?php echo $comment->userLink; ?>" title="View <?php echo $comment->userName; ?> profile" target="_blank" rel="nofollow">
<?php echo $comment->userName; ?>
</a>
<?php else: ?>
<a rel="nofollow"><?php echo $comment->userName; ?></a>
<?php endif; ?>
</div>
<div class="date">
 <?php echo JHTML::_('date', $comment->commentDate, JText::_('K2_DATE_FORMAT_COM_MARIO')); ?>
</div>
<p><?php echo $comment->commentText; ?>
<?php
// USER DESCRIPTION
$thisUserdata =& JFactory::getUser($comment->userID);
echo $thisUserdata->profile->description;
?>
</div>
</div>
</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; ?>