A-A+

EcShop在分类商品列表页显示品牌数量

2012年10月06日 编程技术 暂无评论

首先打开根目录,打到品牌筛选的代码段

[code lang="php"]
$brands_num=0;
foreach ($brands AS $key => $val)
{
$temp_key = $key + 1;
$brands[$temp_key]['brand_name'] = $val['brand_name'];
$brands[$temp_key]['url'] = build_uri('category', array('ci
d' => $cat_id, 'bid' => $val['brand_id'], 'price_min'=>$pri
ce_min, 'price_max'=> $price_max, 'filter_attr'=>$filter_at
tr_str), $cat['cat_name']);
/* 判断品牌是否被选中 */
if ($brand == $brands[$key]['brand_id'])
{
$brands[$temp_key]['selected'] = 1;
}
else
{
$brands[$temp_key]['selected'] = 0;
}
$brands_num=$brands_num+1;
}
[/code]

加入部分代码,然后赋值给模板

[code lang="php"]
$smarty->assign('page_title', $position['title']); // 页面标题
$smarty->assign('ur_here', $position['ur_here']); // 当前位置
$smarty->assign('brands_num', $brands_num);
[/code]

最后在模板里使用 {$brands_num} 显示即可,顺便帖一下当前分类的品牌列表代码:

[code lang="php"]


[/code]

标签:

给我留言

Copyright © 小虎博客 保留所有权利.   Theme  Ality

用户登录