请选择 进入手机版 | 继续访问电脑版
 找回密码
 立即注册

QQ登录

只需一步,快速开始

在ECSHOP主页或者列表页中调用显示评论数量和评论级别

第一步:修改FTP根目录中的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) AS comment_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'];
复制代码
在此文件中继续找以下代码(设置缓存机制)
  1. $smarty->caching = true;
复制代码
替换为:
  1. $smarty->caching = false;
复制代码
第二步:
模板文件修改说明:
themes/你的模板文件夹名称/library/goods_list.lbi 文件,在需要显示评论数目的位置调用以下代码:

  1. <P>评论数:{$goods.comment_count}<br></P>
  2. <P>等    级:{$goods.comment_rank}</P>
复制代码
回复

使用道具 举报

大神点评1

test123 2014-3-17 14:28:01 显示全部楼层
顶了,支持一下
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

    热门帖子
  • 精华
  • 新帖
快速回复 返回顶部 返回列表