您现在的位置是:首页 > 教程 > ecshop商城教程ecshop商城教程
ecshop任何页面调用指定商品分类下面精品商品的实现方法
听蓉2024-05-13 22:44:44ecshop商城教程已有4人查阅
导读ECSHOP商城任何页面调用指定商品分类下面精品商品,比如首页,商品页面,分类页面,调用指定商品分类下面的精品商品。
ECSHOP商城任何页面调用指定商品分类下面精品商品,比如首页,商品页面,分类页面,调用指定商品分类下面的精品商品。
例如:商城首页和商品页面
1,打开index.php或者goods.php 在最下面?>前面加
/** * 获得cat_id精品列表。 * * @access private * @param integer * @return array */ function index_get_cat_id_goods_best_list($cat_id, $num) { $sql = 'Select g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.shop_price, g.promote_price, ' . "promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, goods_img, " . "g.is_best, g.is_new, g.is_hot, g.is_promote " . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . "Where g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND g.is_best = 1 AND (" . $cat_id . " OR " . get_extension_goods($cat_id) .")"; $cats = get_children($cat_id); $where = !empty($cats) ? "AND ($cats OR " . get_extension_goods($cats) . ") " : ''; $sql .=$where." LIMIT $num"; $res = $GLOBALS['db']->getAll($sql); $goods = array(); foreach ($res AS $idx => $row) { $goods[$idx]['id'] = $row['article_id']; $goods[$idx]['id'] = $row['goods_id']; $goods[$idx]['name'] = $row['goods_name']; $goods[$idx]['brief'] = $row['goods_brief']; $goods[$idx]['brand_name'] = $row['brand_name']; $goods[$idx]['goods_style_name'] = add_style($row['goods_name'],$row['goods_name_style']); $goods[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; $goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'],$row['goods_name_style']); $goods[$idx]['market_price'] = price_format($row['market_price']); $goods[$idx]['shop_price'] = price_format($row['shop_price']); $goods[$idx]['thumb'] = empty($row['goods_thumb']) ? $GLOBALS['_CFG']['no_picture'] : $row['goods_thumb']; $goods[$idx]['goods_img'] = empty($row['goods_img']) ? $GLOBALS['_CFG']['no_picture'] : $row['goods_img']; $goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); } return $goods; }
2. index.php 的 $smarty->assign('shop_notice', $_CFG['shop_notice']); // 商店公告
下面增加:
$smarty->assign('cat_id8_best_goods', index_get_cat_id_goods_best_list(8,9));//注意这里的8是商品分类id,商品数量9
3.商城首页增加:
<!-- {foreach from=$cat_id8_best_goods item=goods name=no}--> <div class="line"> <div class="item"> <span class="no">{$smarty.foreach.no.iteration}</span> <p class="pic"><a href="{$goods.url}"><img src="{$goods.thumb}" alt="{$goods.name|escape:html}" class="B_blue" /></a></p> <p class="name"> <a href="{$goods.url}" title="{$goods.name|escape:html}">{$goods.name|escape}</a></p> <p class="price"> <span class="goodsPrice"> <!-- {if $goods.promote_price neq ""} --> {$goods.promote_price} <!-- {else}--> {$goods.shop_price} <!--{/if}--> </span> </p> </div> </div> <div style="clear:both"></div> <!-- {/foreach} -->
例如:商城首页和商品页面
1,打开index.php或者goods.php 在最下面?>前面加
/** * 获得cat_id精品列表。 * * @access private * @param integer * @return array */ function index_get_cat_id_goods_best_list($cat_id, $num) { $sql = 'Select g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.shop_price, g.promote_price, ' . "promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, goods_img, " . "g.is_best, g.is_new, g.is_hot, g.is_promote " . 'FROM ' . $GLOBALS['ecs']->table('goods') . ' AS g ' . "Where g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND g.is_best = 1 AND (" . $cat_id . " OR " . get_extension_goods($cat_id) .")"; $cats = get_children($cat_id); $where = !empty($cats) ? "AND ($cats OR " . get_extension_goods($cats) . ") " : ''; $sql .=$where." LIMIT $num"; $res = $GLOBALS['db']->getAll($sql); $goods = array(); foreach ($res AS $idx => $row) { $goods[$idx]['id'] = $row['article_id']; $goods[$idx]['id'] = $row['goods_id']; $goods[$idx]['name'] = $row['goods_name']; $goods[$idx]['brief'] = $row['goods_brief']; $goods[$idx]['brand_name'] = $row['brand_name']; $goods[$idx]['goods_style_name'] = add_style($row['goods_name'],$row['goods_name_style']); $goods[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name']; $goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'],$row['goods_name_style']); $goods[$idx]['market_price'] = price_format($row['market_price']); $goods[$idx]['shop_price'] = price_format($row['shop_price']); $goods[$idx]['thumb'] = empty($row['goods_thumb']) ? $GLOBALS['_CFG']['no_picture'] : $row['goods_thumb']; $goods[$idx]['goods_img'] = empty($row['goods_img']) ? $GLOBALS['_CFG']['no_picture'] : $row['goods_img']; $goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']); } return $goods; }
2. index.php 的 $smarty->assign('shop_notice', $_CFG['shop_notice']); // 商店公告
下面增加:
$smarty->assign('cat_id8_best_goods', index_get_cat_id_goods_best_list(8,9));//注意这里的8是商品分类id,商品数量9
3.商城首页增加:
<!-- {foreach from=$cat_id8_best_goods item=goods name=no}--> <div class="line"> <div class="item"> <span class="no">{$smarty.foreach.no.iteration}</span> <p class="pic"><a href="{$goods.url}"><img src="{$goods.thumb}" alt="{$goods.name|escape:html}" class="B_blue" /></a></p> <p class="name"> <a href="{$goods.url}" title="{$goods.name|escape:html}">{$goods.name|escape}</a></p> <p class="price"> <span class="goodsPrice"> <!-- {if $goods.promote_price neq ""} --> {$goods.promote_price} <!-- {else}--> {$goods.shop_price} <!--{/if}--> </span> </p> </div> </div> <div style="clear:both"></div> <!-- {/foreach} -->
本文标签:
很赞哦! (0)
暂无内容 |
暂无内容 |
相关文章
暂无内容 |
暂无内容 |
随机图文
ecshop调用很新文章在任何页面显示或者随机文章
ECSHOP在任何页面调用很新文章或者随机文章步:一、让很新文章变成随机文章打开根目录下 index.php 文件查找:' ORDER BY a.artiecshop用户中心的订单详情页怎么显示商品缩略图
用户中心 >> 我的订单 >> 查看订单详细,要如何加入商品缩略图呢?1、修改 includes/lib_order.php ,找到 order_goods 函数部分,大概在467行左右将ecshop浏览历史商品按照点击的先后进行排序的修改方法
在Ecshop中,浏览历史目前默认的显示顺序是按照商品的ID排序的~~~怎么样能让它按照浏览的先后进行排序呢?ecshop后台会员列表增加显示会员等级
目前的ECSHOP系统后台的会员列表默认是不显示会员等级的,它只是在会员搜索功能里面提供了一个按照“会员等级”搜索的功能,这样显示的有些不支援
留言与评论 (共有 0 条评论) |