K2_content模块等级 [英] K2_content module rating
本文介绍了K2_content模块等级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在category_item.php中重建标准的K2等级,以查看等级,以星号显示为数字.
I've been reconstructing the standard K2 rating in the category_item.php to view ratings from to show as stars to show as number.
我所做的是,我替换了这段代码:
What I did was, I replaced this code:
<?php if($this->item->params->get('catItemRating')): ?>
<div id="catItemRatingBlock">
<div class="itemRatingForm">
<ul class="itemRatingList">
<li class="itemCurrentRating" id="itemCurrentRating<?php echo $this->item->id; ?>" style="width:<?php echo $this->item->votingPercentage; ?>%;"></li>
<li><a href="#" rel="<?php echo $this->item->id; ?>" class="one-star">1</a></li>
<li><a href="#" rel="<?php echo $this->item->id; ?>" class="two-stars">2</a></li>
<li><a href="#" rel="<?php echo $this->item->id; ?>" class="three-stars">3</a></li>
<li><a href="#" rel="<?php echo $this->item->id; ?>" class="four-stars">4</a></li>
<li><a href="#" rel="<?php echo $this->item->id; ?>" class="five-stars">5</a></li>
</ul>
</div>
</div>
<?php endif; ?>
使用以下代码:
<?php if($this->item->params->get('catItemRating')): ?>
<div id="catItemRatingBlock">
<div class="itemRatingForm">
<?php
$rating_sum=0;
$rating_cont=0;
$db =& JFactory::getDBO();
$query='SELECT * FROM #__k2_rating WHERE itemID='. $this->item->id;
$db->setQuery($query);
$votes=$db->loadObject();
$rating_sum = intval($votes->rating_sum);
$rating_count = intval($votes->rating_count);
$evaluate = ($rating_count==0) ? "0" : number_format($rating_sum/$rating_count,1);
$evaluate = str_replace('.0', '', $evaluate);
$output=" Rating: ". $evaluate."/5";
echo $output;
?>
</div>
</div>
<?php endif; ?>
我想要的是它也可以在K2模块上工作.我试图使用我在上面编写的相同代码在k2内容模块中实现它,但这根本不起作用.
And what I want is for it to work on the K2 module as well. I tried to use the same code that I wrote above here to achieve it in k2 content module but that doesn't work at all.
任何人都知道如何实现吗?
Anyone know how to pull it off?
推荐答案
替换
<?php if($this->item->params->get('catItemRating')): ?>
具有:
<?php if($params->get('catItemRating')): ?>
这篇关于K2_content模块等级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文