在做模板时,首页新品调用评论等级,就让68ecshop的技术来为 大家简单的介绍下吧!
第一步:找到根目录下includes/lib_goods.lbi,在尾部添加函数
function get_comment_rank($goods_id){
if(empty ($goods_id)){
return '5';
}
$sql = "select AVG(comment_rank) as goods_rank from".$GLOBALS ['ecs']->table('comment').
"where id_value = '$goods_id' AND comment_type = 0 AND parent_id = 0 AND status =1";
$val = $GLOBALS['db'] -> getOne($sql);
$val = ceil ($val) == 0?5:ceil($val);
return $val;
}
第二步:找到 get_recommend_goods()函数,
在 $goods[$idx]['name'] = $row ['goods_name'];下添加
$goods[$idx]['goods_rank'] = get_comment_rank($row ['goods_id']);
第三步:页面中调用{$goods.goods_rank},这样就可以在首页调出新品的评 论等级了。
建站咨询热线
18503087281