您现在的位置是:首页 > cms教程 > Ecshop商城教程Ecshop商城教程
ecshop品牌列表页实现分页的方法
白易2024-01-16Ecshop商城教程已有人查阅
导读ECSHOP品牌列表页实现分页修改教程ECSHOP品牌列表页brand.php默认是没有分页的,如果品牌太多了,就不方便了。所以民能加上一个分页功能。 步
ECSHOP品牌列表页实现分页修改教程
ECSHOP品牌列表页brand.php默认是没有分页的,如果品牌太多了,就不方便了。所以民能加上一个分页功能。
步骤一:
打开根目录 brand.php 文件
查找:
if (empty($brand_id)){ /* 缓存编号 */ $cache_id = sprintf('%X', crc32($_CFG['lang'])); if (!$smarty->is_cached('brand_list.dwt', $cache_id)) { assign_template(); $position = assign_ur_here('', $_LANG['all_brand']); $smarty->assign('page_title', $position['title']); // 页面标题 $smarty->assign('ur_here', $position['ur_here']); // 当前位置 $smarty->assign('categories', get_categories_tree()); // 分类树 $smarty->assign('helps', get_shop_help()); // 网店帮助 $smarty->assign('top_goods', get_top10()); // 销售排行 $smarty->assign('brand_list', get_brands()); } $smarty->display('brand_list.dwt', $cache_id); exit();}
修改为:
if (empty($brand_id)){assign_template(); $position = assign_ur_here('', $_LANG['all_brand']); $smarty->assign('page_title', $position['title']); // 页面标题 $smarty->assign('ur_here', $position['ur_here']); // 当前位置 $smarty->assign('categories', get_categories_tree()); // 分类树 $smarty->assign('helps', get_shop_help()); // 网店帮助 $smarty->assign('top_goods', get_top10()); // 销售排行 $sql = "SELECT count(*) as brand_count from ( select b.brand_id ". "FROM " . $GLOBALS['ecs']->table('brand') . "AS b, ". $GLOBALS['ecs']->table('goods') . " AS g ". "WHERE g.brand_id = b.brand_id AND is_show = 1 " . " AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 ". "GROUP BY b.brand_id ) AS gb"; $brand_count=$GLOBALS['db']->getOne($sql); //品牌(含有商品的)数量 $page = !empty($_REQUEST['page']) && intval($_REQUEST['page']) > 0 ? intval($_REQUEST['page']) : 1; $size = 30; $max_page = ($brand_count> 0) ? ceil($brand_count / $size) : 1; if ($page > $max_page) {$page = $max_page;} $start=($page - 1) * $size; $sql = "SELECT b.brand_id, b.brand_name, b.brand_logo, b.brand_desc, COUNT(*) AS goods_num, IF(b.brand_logo > '', '1', '0') AS tag ". "FROM " . $GLOBALS['ecs']->table('brand') . "AS b, ". $GLOBALS['ecs']->table('goods') . " AS g ". "WHERE g.brand_id = b.brand_id AND is_show = 1 " . " AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 ". "GROUP BY b.brand_id HAVING goods_num > 0 ORDER BY tag DESC, b.sort_order ASC limit $start,$size"; $row = $GLOBALS['db']->getAll($sql); foreach ($row AS $key => $val) { $row[$key]['url'] = build_uri('brand', array('cid' => $cat, 'bid' => $val['brand_id']), $val['brand_name']); $row[$key]['brand_desc'] = htmlspecialchars($val['brand_desc'],ENT_QUOTES); } $pager['search'] = array( ); $pager = get_pager('brand.php', $pager['search'], $brand_count, $page, $size); $pager['display'] = $display; $smarty->assign('pager', $pager); $smarty->assign('brand_list', $row); $smarty->display('brand_list.dwt'); exit();}
其中, 0行的
$size = 30;
表示每页的数量
第二步:
打开模板文件 brand_list.dwt
在需要显示分页的地方加入以下代码:
大功告成
ECSHOP品牌列表页brand.php默认是没有分页的,如果品牌太多了,就不方便了。所以民能加上一个分页功能。
步骤一:
打开根目录 brand.php 文件
查找:
if (empty($brand_id)){ /* 缓存编号 */ $cache_id = sprintf('%X', crc32($_CFG['lang'])); if (!$smarty->is_cached('brand_list.dwt', $cache_id)) { assign_template(); $position = assign_ur_here('', $_LANG['all_brand']); $smarty->assign('page_title', $position['title']); // 页面标题 $smarty->assign('ur_here', $position['ur_here']); // 当前位置 $smarty->assign('categories', get_categories_tree()); // 分类树 $smarty->assign('helps', get_shop_help()); // 网店帮助 $smarty->assign('top_goods', get_top10()); // 销售排行 $smarty->assign('brand_list', get_brands()); } $smarty->display('brand_list.dwt', $cache_id); exit();}
修改为:
if (empty($brand_id)){assign_template(); $position = assign_ur_here('', $_LANG['all_brand']); $smarty->assign('page_title', $position['title']); // 页面标题 $smarty->assign('ur_here', $position['ur_here']); // 当前位置 $smarty->assign('categories', get_categories_tree()); // 分类树 $smarty->assign('helps', get_shop_help()); // 网店帮助 $smarty->assign('top_goods', get_top10()); // 销售排行 $sql = "SELECT count(*) as brand_count from ( select b.brand_id ". "FROM " . $GLOBALS['ecs']->table('brand') . "AS b, ". $GLOBALS['ecs']->table('goods') . " AS g ". "WHERE g.brand_id = b.brand_id AND is_show = 1 " . " AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 ". "GROUP BY b.brand_id ) AS gb"; $brand_count=$GLOBALS['db']->getOne($sql); //品牌(含有商品的)数量 $page = !empty($_REQUEST['page']) && intval($_REQUEST['page']) > 0 ? intval($_REQUEST['page']) : 1; $size = 30; $max_page = ($brand_count> 0) ? ceil($brand_count / $size) : 1; if ($page > $max_page) {$page = $max_page;} $start=($page - 1) * $size; $sql = "SELECT b.brand_id, b.brand_name, b.brand_logo, b.brand_desc, COUNT(*) AS goods_num, IF(b.brand_logo > '', '1', '0') AS tag ". "FROM " . $GLOBALS['ecs']->table('brand') . "AS b, ". $GLOBALS['ecs']->table('goods') . " AS g ". "WHERE g.brand_id = b.brand_id AND is_show = 1 " . " AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 ". "GROUP BY b.brand_id HAVING goods_num > 0 ORDER BY tag DESC, b.sort_order ASC limit $start,$size"; $row = $GLOBALS['db']->getAll($sql); foreach ($row AS $key => $val) { $row[$key]['url'] = build_uri('brand', array('cid' => $cat, 'bid' => $val['brand_id']), $val['brand_name']); $row[$key]['brand_desc'] = htmlspecialchars($val['brand_desc'],ENT_QUOTES); } $pager['search'] = array( ); $pager = get_pager('brand.php', $pager['search'], $brand_count, $page, $size); $pager['display'] = $display; $smarty->assign('pager', $pager); $smarty->assign('brand_list', $row); $smarty->display('brand_list.dwt'); exit();}
其中, 0行的
$size = 30;
表示每页的数量
第二步:
打开模板文件 brand_list.dwt
在需要显示分页的地方加入以下代码:
大功告成
本文标签:
很赞哦! ()
相关教程
图文教程
ecshop怎么做淘宝客
第一步下载文件。安装好ECSHOP,然后通过PTF工具下载2个文件到本地进行修改。这个2个文件分别是goods.dwt和goods_list.lbi文件,位置在你根目录下的
ecshop结算页购物车提交订单页面显示商品缩略图的方法
ECSHOP系统,在购物车页面,是可以显示商品缩略图的,但是ECSHOP在订单提交的页面却不支持显示缩略图,好在ECSHOP是开源的,通过以下方法可以实现
ecshop底部版权结构分析和修改
我们在ecshop二次开发和ecshop使用过程中,往往需要对ecshop底部进行处理和修改.比如ecshop底部版权问题,ecshop底部程序结构问题.也有很多朋友咨询ecshop底部的一些修改问题。
ecshop会员怎么实现每天登陆和长时间停留送积分
ECSHOP会员每天 次登录赠送积分的includes\lib_main.php,查找/* 更新登录时间,登录次数及登录ip */,添加:
相关源码
-
(自适应)刷卡pos机数据移动支付设备电子科技pbootcms模板下载本模板为POS机设备制造商、移动支付终端服务商和科技企业设计,基于PbootCMS系统开发,提供完整的在线展示平台解决方案,满足支付设备行业特有的展示需求。查看源码 -
自适应黑色简繁双语轴承齿轮机械设备制造网站模板该模板为轴承齿轮机械制造企业提供一体化网站建设方案,着重解决行业特有的多语言展示、移动端适配和高效率内容管理需求,帮助企业精准展示产品特性与工艺流程查看源码 -
(自适应)包装机贴标机设备网站源码免费下载基于PbootCMS内核开发的响应式企业模板,为包装机械、贴标设备等工业领域打造,通过数字化展示提升企业专业形象。查看源码 -
(自适应)代理记账财务会计咨询服务个人公司网站模板该响应式网站模板为代理记账、财政咨询及财务会计类企业设计,基于PbootCMS内核开发。通过自适应手机端的HTML5技术,帮助企业高效构建专业财税服务平台查看源码 -
(自适应响应式)高端家用办公家具家居桌椅pbootcms模板下载为办公家具企业设计的响应式网站模板,涵盖产品展示、案例呈现、企业介绍等核心模块。通过可视化后台可快速发布实木桌椅、系统家具、办公屏风等产品信息,帮助客户直观了解材质参数与空间搭配方案。查看源码 -
(PC+WAP)绿色产品环保设备垃圾桶厂家公司网站pbootcms模板为垃圾桶生产商、环保设备企业打造的高端响应式门户模板,基于PbootCMS开源内核深度开发。采用HTML5自适应架构,无缝实现PC与手机端数据实时同步与交互优化查看源码
| 分享笔记 (共有 篇笔记) |
