国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 建站經驗 > 正文

ECSHOP全部品牌分頁功能實現

2024-04-25 20:34:30
字體:
來源:轉載
供稿:網友

ecshop的全部品牌列表是沒有分頁的,今天分享一下自己的分頁代碼。

“在全部品牌頁實現分頁換頁功能”,對商品品牌較多的朋友也許會有幫助。

1、打開brand.php

找到

if (empty($brand_id))

{

再找到

exit();

}

將這兩者之間的代碼全部替換為下面代碼

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); //品牌(含有商品的)數量www.bcty365.com

$page = !empty($_REQUEST['page']) && intval($_REQUEST['page']) > 0 ? intval($_REQUEST['page']) : 1;

$size = 3;

$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');

2、打開 模板文件 brand_list.dwt

在你想要顯示換頁信息的地方加入下面代碼

<!-- #BeginLibraryItem "/library/pages.lbi" --><!-- #EndLibraryItem -->

如果你使用的是官方默認模板,那么在

<div class="dashed"></div>

這行代碼下面加

<!-- #BeginLibraryItem "/library/pages.lbi" --><!-- #EndLibraryItem -->

比較合適。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 东乌珠穆沁旗| 许昌县| 隆昌县| 天等县| 五台县| 江陵县| 南平市| 永德县| 龙江县| 鱼台县| 乌兰县| 英吉沙县| 盘山县| 康保县| 台南县| 鹤岗市| 哈密市| 许昌县| 马边| 清新县| 耿马| 巩义市| 同江市| 株洲县| 读书| 孝义市| 鹤岗市| 晋城| 托克逊县| 磴口县| 潼关县| 肥乡县| 密山市| 柞水县| 怀远县| 东方市| 垫江县| 西藏| 永胜县| 芷江| 琼结县|