您现在的位置是:首页 > 教程 > ecshop商城教程ecshop商城教程
ecshop品牌列表页实现分页的方法
白易2024-01-16 20:23:16ecshop商城教程已有11人查阅
导读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
在需要显示分页的地方加入以下代码:
大功告成
本文标签:
很赞哦! (0)
暂无内容 |
暂无内容 |
相关文章
暂无内容 |
暂无内容 |
随机图文
ecshop中收货人信息的省市区怎么设成非必选项
一般面向国外用户的ECSHOP商城,可能会有这方面的需求:【将Ecshop中收货人信息的省市区设成非必选项】,其实也就是只留一个“请选择国家”的下拉选择框。ecshop收货人收货地址信息的省市区改成非必选项
今天为大家详细解说一下ECSHOP收货人收货地址信息的省市区改成非必选项代码号ECSHOP视频教程也再不断的完善与跟进,期待大家的关注!希望在ECSHOP的道路上ecshop数据库取数据,查询数据的写法
我结合eschop二次开发一些常见的开发例子.来谈谈ecshop的数据库类和方法是如何处理数据库。让我们熟练掌握ecshop数据库的操作。ecshop后台会员列表增加显示会员等级
目前的ECSHOP系统后台的会员列表默认是不显示会员等级的,它只是在会员搜索功能里面提供了一个按照“会员等级”搜索的功能,这样显示的有些不支援
留言与评论 (共有 0 条评论) |