花魁直播高品质美女在线视频互动社区 - 花魁直播官方版

 歡迎來到素材無憂網(wǎng),按 + 收藏我們
登錄 注冊(cè) 退出 找回密碼

ecshop品牌列表頁(yè)實(shí)現(xiàn)分頁(yè)的方法

時(shí)間: 2024-02-25 10:43 閱讀: 作者:素材無憂網(wǎng)

ECSHOP品牌列表頁(yè)實(shí)現(xiàn)分頁(yè)修改教程
ECSHOP品牌列表頁(yè)brand.php默認(rèn)是沒有分頁(yè)的,如果品牌太多了,就不方便了。所以民能加上一個(gè)分頁(yè)功能。
步驟一:
打開根目錄 brand.php 文件
查找:
if (empty($brand_id)){ /* 緩存編號(hào) */ $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']); // 頁(yè)面標(biāo)題 $smarty->assign('ur_here', $position['ur_here']); // 當(dāng)前位置 $smarty->assign('categories', get_categories_tree()); // 分類樹 $smarty->assign('helps', get_shop_help()); // 網(wǎng)店幫助 $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']); // 頁(yè)面標(biāo)題 $smarty->assign('ur_here', $position['ur_here']); // 當(dāng)前位置 $smarty->assign('categories', get_categories_tree()); // 分類樹 $smarty->assign('helps', get_shop_help()); // 網(wǎng)店幫助 $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); //品牌(含有商品的)數(shù)量 $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;
表示每頁(yè)的數(shù)量
第二步:
打開模板文件 brand_list.dwt
在需要顯示分頁(yè)的地方加入以下代碼:
大功告成

版權(quán)聲明: 本站資源均來自互聯(lián)網(wǎng)或會(huì)員發(fā)布,如果侵犯了您的權(quán)益請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)刪除!謝謝!

轉(zhuǎn)載請(qǐng)注明: ecshop品牌列表頁(yè)實(shí)現(xiàn)分頁(yè)的方法

標(biāo)簽: ecshop品牌列表  
相關(guān)文章
推薦文章
模板推薦