ECshop二次开发 ECSHOP首页显示积分商城里的商品
生活随笔
收集整理的這篇文章主要介紹了
ECshop二次开发 ECSHOP首页显示积分商城里的商品
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
以ECSHOP2.7.2官方默認模板為基礎
1)、首先打開 index.php 文件,在最末尾增加下面函數,注意千萬不要寫到 “?>” 的外面去,要加在“?>”的前面,加以下代碼:
/** * 獲得積分商城熱門商品 * * @param int $limit 列出條數 * @param int $ishot 是否只顯示熱銷 * @return array */ function index_get_exchange($limit=3,$ishot=0) {/* 獲得熱門積分商品列表 */ $sql_ishot=$ishot ? " AND eg.is_hot=1 " : ""; $sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style, eg.exchange_integral, ' . ' g.goods_type,g.goods_brief, g.goods_thumb, g.goods_img, eg.is_hot ' . ' FROM ' . $GLOBALS['ecs']->table('exchange_goods') . ' AS eg LEFT JOIN ' . $GLOBALS['ecs']->table('goods') . ' AS g ON g.goods_id = eg.goods_id ' . ' WHERE eg.is_exchange = 1 AND g.is_delete = 0 '. $sql_ishot .' limit '.$limit;$res = $GLOBALS['db']->getAll($sql);$arr = array();foreach($res AS $idx => $row){ $arr[$idx]['name'] = $row['goods_name']; $arr[$idx]['goods_brief'] = $row['goods_brief']; $arr[$idx]['goods_style_name'] = add_style($row['goods_name'],$row['goods_name_style']); $arr[$idx]['exchange_integral'] = $row['exchange_integral']; $arr[$idx]['type'] = $row['goods_type']; $arr[$idx]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true); $arr[$idx]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']); $arr[$idx]['url'] = build_uri('exchange_goods', array('gid'=>$row['goods_id']), $row['goods_name']);}return $arr; }然后繼續在 index.php 文件中 找到?
$smarty->assign('shop_notice', $_CFG['shop_notice']); // 商店公告
?
在它下邊另起一行增加如下代碼
?
$smarty->assign('goods_exchange_list',index_get_exchange(6,0)); //積分商城
?
如果你想只顯示熱銷的積分商品,只需將上面代碼稍作修改即可
?
$smarty->assign('goods_exchange_list',index_get_exchange(6,1)); //積分商城
?
2)、下面繼續修改模板文件 themes/default/index.dwt 在你想顯示積分商城商品的地方,加入下面代碼段
3)、到后臺清除下緩存,然后刷新首頁就能看到效果了
轉載于:https://www.cnblogs.com/nuanxin/p/10109911.html
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的ECshop二次开发 ECSHOP首页显示积分商城里的商品的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: sqlserver生成脚本
- 下一篇: 12.12