給ECShop添加最新評論,ECShop添加最新評論_PHP教程

來源:互聯網
上載者:User

給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裡面構建自訂...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.