K2_content module rating(K2_content 模块评分)
问题描述
我一直在 category_item.php 中重建标准的 K2 评分,以查看评分从显示为星星到显示为数字.
我所做的是,我替换了这段代码:
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="一星">1</a></li><li><a href="#" rel="<?php echo $this->item->id; ?>"class="两星">2<li><a href="#" rel="<?php echo $this->item->id; ?>"class="三星级">3</a></li><li><a href="#" rel="<?php echo $this->item->id; ?>"class="四星">4</a></li><li><a href="#" rel="<?php echo $this->item->id; ?>"class="五颗星">5</a></li><?php endif;?>
使用此代码:
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=" 评分:".$评估."/5";回声$输出;?>
<?php endif;?>
我想要的是它也能在 K2 模块上运行.我尝试使用我在上面写的相同代码在 k2 内容模块中实现它,但这根本不起作用.
有人知道怎么把它拉下来吗?
替换
item->params->get('catItemRating')): ?>
与:
get('catItemRating')): ?>
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; ?>
with this code:
<?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; ?>
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?
Replace
<?php if($this->item->params->get('catItemRating')): ?>
with:
<?php if($params->get('catItemRating')): ?>
这篇关于K2_content 模块评分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:K2_content 模块评分


基础教程推荐
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- 在多维数组中查找最大值 2021-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- 超薄框架REST服务两次获得输出 2022-01-01