給ECShop添加最新評論,ECShop添加最新評論
我直接寫上操作步驟吧,看下思路,相信大家也會了
第一步:
在includes/lib_goods.php裡面構建自訂函數
複製代碼 代碼如下:
/**
* 擷取最近評論
*
* @return array
*/
function get_latest_comment($limit_num)
{
$sql = "SELECT c.content,c.add_time,g.goods_id,g.goods_name FROM ".$GLOBALS['ecs']->table('comment')." AS c
LEFT JOIN ".$GLOBALS['ecs']->table('goods')." AS g on c.id_value=g.goods_id
WHERE c.status=1
LIMIT ".$limit_num;
$res = $GLOBALS['db']->getAll($sql);
return $res;
}
第二步:
在根目錄的goods.php的$smarty->assign('goods_rank', get_goods_rank($goods_id)); // 商品的銷售排名
下面添加以下代碼
複製代碼 代碼如下:
$smarty->assign('comments_latest', get_latest_comment(10)); //擷取最新品論
第三步:
在library目錄下建立comments_latest.lbi檔案
第四步:
在模板檔案goods.dwt中使用以下代碼即可在商品詳情頁面中調用“最新評論”
複製代碼 代碼如下:
http://www.bkjia.com/PHPjc/939408.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/939408.htmlTechArticle給ECShop添加最新評論,ECShop添加最新評論 我直接寫上操作步驟吧,看下思路,相信大家也會了 第一步: 在includes/lib_goods.php裡面構建自訂...