欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

給ECShop添加最新評論

 更新時(shí)間:2015年01月07日 15:31:21   投稿:hebedich  
這篇文章主要介紹了給ECShop添加最新評論的方法及代碼分享,需要的朋友可以參考下

我直接寫上操作步驟吧,看下思路,相信大家也會了

第一步:

在includes/lib_goods.php里面構(gòu)建自定義函數(shù)

復(fù)制代碼 代碼如下:

/**
 * 獲取最近評論
 *
 * @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));                       // 商品的銷售排名

下面添加以下代碼

復(fù)制代碼 代碼如下:

$smarty->assign('comments_latest',     get_latest_comment(10));                 //獲取最新品論

 第三步:

在library目錄下創(chuàng)建comments_latest.lbi文件

第四步:

在模板文件goods.dwt中使用以下代碼即可在商品詳情頁面中調(diào)用“最新評論”

復(fù)制代碼 代碼如下:

<!-- #BeginLibraryItem "/library/comments_latest.lbi" --><!-- #EndLibraryItem -->

相關(guān)文章

最新評論