doubi9615 2012-08-26 21:48
浏览 47

K2_content模块评级

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?

  • 写回答

1条回答 默认 最新

  • douyi6168 2015-04-17 15:54
    关注

    Replace

    <?php if($this->item->params->get('catItemRating')): ?>
    

    with:

    <?php if($params->get('catItemRating')): ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。