Ecshop分类页面的品牌筛选默认不显示该品牌下商品数量,如果需要显示,可能通过一下方法进行修改。
首先打开category.php,搜索函数$brands,大约438行,在对应位置添加下面红色代码。
foreach ($brands AS $key => $val)
{
$temp_key = $key + 1;
$brands[$temp_key]['brand_name'] = $val['brand_name'];
$brands[$temp_key]['goods_num'] = $val['goods_num'];
$brands[$temp_key]['url'] = build_uri('category', array('cid' => $cat_id, 'bid' => $val['brand_id'], 'price_min'=>$price_min, 'price_max'=> $price_max, 'filter_attr'=>$filter_attr_str), $cat['cat_name']);
/* 判断品牌是否被选中 */
if ($brand == $brands[$key]['brand_id'])
{
$brands[$temp_key]['selected'] = 1;
}
else
{
$brands[$temp_key]['selected'] = 0;
}
}
$brands[0]['brand_name'] = $_LANG['all_attribute'];
$brands[0]['goods_num'] = '';
$brands[0]['url'] = build_uri('category', array('cid' => $cat_id, 'bid' => 0, 'price_min'=>$price_min, 'price_max'=> $price_max, 'filter_attr'=>$filter_attr_str), $cat['cat_name']);
$brands[0]['selected'] = empty($brand) ? 1 : 0;
$smarty->assign('brands', $brands);
然后打开对应模板文件 category.dwt,找到
<dl class="xm-filter-list category-filter-list clearfix">
<dt>品牌:</dt>
对应添加一下红色代码:
<!--{foreach from=$brands item=brand}-->
<!-- {if $brand.selected} -->
<li class="current"><a>{$brand.brand_name}({$brand.goods_num})</a></li>
<!-- {else} -->
<li><a href="{$brand.url}">{$brand.brand_name}({$brand.goods_num})</a></li>
<!-- {/if} -->
<!--{/foreach}-->
效果如下图:
相关文章
ecshop出现Warning: Invalid argument supplied for foreach()错误2019-02-26
Ecshop 分类页产品列表不同分类调用不同产品属性2018-03-08
ECSHOP商品属性调用到任意页面方法2018-03-01
ECSHOP商品列表页显示每个商品的品牌2018-02-28
ecshop调整默认商品图片排序2018-02-27
ecshop各个页面调用商品销售量方法2016-09-23
ecshop mobile首页循环显示分类及分类下商品2016-09-23
ecshop后台添加虚拟销量以及前台显示销量2016-09-22
ecshop重新导入数据库,管理员和密码正确登录失败2016-09-21
ecshop 共享首页推荐商品调用商品品牌方法2015-08-06