在ECSHOP主页设置评论数量和评论级别

2016-07-07 14:55 来源:www.chinab4c.com 作者:ecshop专家



修改category.php 文件

找到下面的
  1. $sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ' .
  2. "IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, g.promote_price, g.goods_type, " .
  3. 'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img ' .
  4. 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' .
  5. 'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' .
  6. "ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' " .
  7. "WHERE $where $ext ORDER BY $sort $order";
复制代码
改成下面的
  1. $sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ' .
  2. "IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price, g.promote_price, g.goods_type, " .
  3. " IFNULL(AVG(r.comment_rank),0) AS comment_rank,IF(r.comment_rank,count(*),0) AScomment_count, ".
  4. 'g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img ' .
  5. 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' .
  6. 'LEFT JOIN ' . $GLOBALS['ecs']->table('member_price') . ' AS mp ' .
  7. "ON mp.goods_id = g.goods_id AND mp.user_rank = '$_SESSION[user_rank]' " .
  8. ' LEFT JOIN'. $GLOBALS['ecs']->table('comment') .' AS r '.
  9. 'ON r.id_value = g.goods_id AND comment_type = 0 AND r.parent_id = 0 AND r.status = 1 ' .
  10. "WHERE $where $ext group by g.goods_id ORDER BY $sort $order";
复制代码
继续找到
  1. $arr[$row['goods_id']]['url']= build_uri('goods', array('gid'=>$row['goods_id']), $row['goods_name']);
复制代码
在下面增加几列
  1. $row['comment_rank']= ceil($row['comment_rank']) == 0 ? 5 : ceil($row['comment_rank']);
  2. $arr[$row['goods_id']]['comment_rank']=$row['comment_rank'];
  3. $arr[$row['goods_id']]['comment_count']=$row['comment_count'];
复制代码
模板修改说明:
htemes/default/library/goods_list.lbi 文件
  1. <a href="javascript:collect({$goods.goods_id});">{$lang.btn_collect}</a>
复制代码
在上面增加以下代码
  1. <img src="images/stars{$goods.comment_rank}.gif"style="width:78px;height:15px;" /><br>
  2. 评论数:{$goods.comment_count}<br>
复制代码
设置缓存机制
  1. 把 category.php 文件的
  2. $smarty->caching = true;
  3. 修改为
  4. $smarty->caching = false;
复制代码
不懂的可以加交流群,免费交流解答。QQ群180035291 QQ群 **15760

回答:
没人顶哦。。。。

这个不错 支持下 谢谢

我自己顶一下哈。。。。

不错,学习!

有图例吗? 谢谢!

支持下。可不可以用分数的12345来区分评论的呢?就和1号店的那种评论风格~

支持

还没看 先支持一下再说

支持了呢 呵呵

支持下,调用成功。非常感谢分享,成功在分类页调用了,但是赐教商品搜索页面如何调用已评论数量等级?

支持。。

ECSHOP学习资料:http://www.phpally.com

这个不错 支持下