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表示通過了的評(píng)論才算 ?comment_type =0表示針對(duì)商品的評(píng)價(jià)
return $GLOBALS['db']->getOne($sql);
}
然后找到 在get_recommend_goods函數(shù)中 大致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}調(diào)用了如果分類下面商品也要顯示已評(píng)論數(shù)量:
$goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
代碼后添加:
$goods[$idx]['evaluation'] ? = get_evaluation_sum($row['goods_id']);
版權(quán)聲明: 本站資源均來自互聯(lián)網(wǎng)或會(huì)員發(fā)布,如果侵犯了您的權(quán)益請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)刪除!謝謝!
轉(zhuǎn)載請(qǐng)注明: ecshop首頁商品顯示已評(píng)論數(shù)量