您现在的位置是:首页 > 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
在需要显示分页的地方加入以下代码:
大功告成

本文标签:

很赞哦! ()

相关教程

相关源码

  • (自适应响应式)html5高档服装定制西服pbootcms模板下载本模板基于PbootCMS内核开发,为服装定制企业和服装品牌量身打造。设计风格时尚现代,充分展现服装行业的审美特质与品牌魅力。采用HTML5响应式技术,确保在各种设备上呈现视觉效果。整站布局注重产品展示与品牌叙事,帮助企业有效展示服装系列与定制服务,提升客户体验。查看源码
  • (自适应响应式)高端珠宝首饰奢侈品pbootcms模板下载本模板为珠宝首饰及奢侈品行业打造,采用PbootCMS内核开发,具备卓越的视觉表现力与商业转化能力。自适应设计确保在手机端呈现产品细节,后台数据实时同步,助您高效展示钻石查看源码
  • (PC+WAP)蓝色智能环保机械设备网站营销型pbootcms模板下载本模板基于PbootCMS系统开发,为环保设备制造企业设计,特别适合展示环保机械、智能装备等产品。采用响应式技术,确保各类设备参数和技术方案在不同终端上都能清晰展示。查看源码
  • 帝国cms7.5文库范文/付费下载/复制付费/带支付源码免费下载本模板为文库、文档分享、知识付费类平台设计,提供完整的内容变现解决方案。系统支持多种内容展示与付费模式,满足不同场景下的内容价值转化需求,帮助平台实现内容资源的有效管理和商业化运营。查看源码
  • (自适应响应式)绿色环保防腐木材轻钢别墅建材pbootcms模板下载本模板为环保防腐木材、轻钢别墅建材类企业设计开发,基于PbootCMS内核构建,充分考虑了建材行业的展示需求与产品特点。模板设计风格自然环保,布局清晰合理,呈现建材产品特性与专业优势,帮助访客直观了解产品特点并建立信任感。查看源码
  • (自适应)英文外贸电子设备网站模板三级子目录基于PbootCMS内核开发的响应式英文网站模板,为外贸企业打造,支持多行业快速适配。通过简洁高效的代码架构,帮助企业低成本构建专业海外形象,实现更好客户触达与订单转化。查看源码
分享笔记 (共有 篇笔记)
验证码:

本栏推荐