function get_evaluation_sum($goods_id)
{
$sql = "SELECT count(*) FROM " . $GLOBALS['ecs']->table('comment') . " WHERE status=1 and comment_type =0 and id_value =".$goods_id ;//status=1表示通过了的评论才算 comment_type =0表示针对商品的评价
return $GLOBALS['db']->getOne($sql);
}
然后找到 在get_recommend_goods函数中 大致325行
$goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
其后添加
$goods[$idx]['evaluation'] = get_evaluation_sum($row['goods_id']);
剩下的就是通过在模板中 用{$goods.evaluation}调用了如果分类下面商品也要显示已评论数量:
$goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
代码后添加:
$goods[$idx]['evaluation'] = get_evaluation_sum($row['goods_id']);
版权声明: 本站资源均来自互联网或会员发布,如果侵犯了您的权益请与我们联系,我们将在24小时内删除!谢谢!
转载请注明: ecshop首页商品显示已评论数量