您现在的位置是:首页 > cms教程 > Ecshop商城教程Ecshop商城教程
ecshop任何页面调用指定商品分类下面精品商品的实现方法
听蓉2024-05-13Ecshop商城教程已有人查阅
导读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} -->
本文标签:
很赞哦! ()
相关教程
图文教程
ecshop5.3/5.4环境lib_base.php on line 346解决方法
然后删除工程目录下的temp文件夹,重新拷贝一份原始的temp文件夹进来,再访问首页,就会发现一切正常了!lib_base.php on line 346解决方法这个错误的的处理是修改文件:
ecshop商品分类页怎么调用商品销售排行
我们可以看到这个 get_top10()里面是空的,没有传参数,所以调用了全部商品的排行。找到商品的分类的程序页面category.php;
ecshop会员怎么实现每天登陆和长时间停留送积分
ECSHOP会员每天 次登录赠送积分的includes\lib_main.php,查找/* 更新登录时间,登录次数及登录ip */,添加:
ecshop商品与文章删除时同时删除商品图片
ECSHOP删除文章或从回收站删除商品,文章内容和商品描述中的图片(位于/images/upload/Image目录)无法删除,时间长了会占用相当大的空间
相关源码
-
(自适应响应式)蓝色环保机械设备网站pbootcms模板HTML5源码下载基于PbootCMS的生态环境技术展示平台,通过内容调整可应用于新能源设备、污水处理、空气净化等环保相关领域。设备参数采用对比表格展示,技术原理支持图文混排;查看源码 -
(PC+WAP)绣花刺绣传统手工工艺pbootcms网站源码下载这款基于PbootCMS的网站模板为刺绣和传统手工艺行业设计,采用优雅的布局和精致的细节处理,能够呈现手工艺品的独特韵味和文化内涵。模板结构合理,功能完善,是手工艺从业者展示作品的理想选择。查看源码 -
(自适应响应式)化妆美容口红唇膏化妆品模板pbootcms源码下载基于PbootCMS开发的响应式模板,为化妆品品牌、美容机构打造,通过优雅的视觉呈现提升产品展示效果与品牌调性。采用时尚杂志排版风格,色卡系统规范产品展示。微交互动画增强用户体验,智能推荐算法提升产品关联展示效果。查看源码 -
(响应式)wordpress模板VieuV4.5主题资讯自媒体博客源码Vieu主题专注于个人博客与企业展示场景,采用响应式设计确保在手机、电脑、平板等多设备上的展示。主题集成会员中心、投稿系统、内容保护等实用功能,满足现代博客网站的建设需求。查看源码 -
自适应建材瓷砖卫浴大理石类pbootcms网站模板源码下载为建材瓷砖、卫浴瓷砖企业打造的高端响应式门户模板,基于PbootCMS内核深度开发。采用前沿HTML5自适应架构,无缝兼容手机端触控交互与PC端展示场景。查看源码 -
(PC+WAP)盆栽绿植观赏植物花卉租赁免费pbootcms网站模板为花卉盆栽租赁、园林绿化企业打造的PbootCMS网站模板,采用较新内核开发,PC与移动端数据实时同步。通过清新自然的视觉设计,精准展现植物养护、花卉展示等业务场景,帮助用户快速建立专业级行业网站。查看源码
| 分享笔记 (共有 篇笔记) |
