全站插件24小时自动发货

实现ecshop中商品分类页分类搜索的功能

ecshop分类页面里面本来就有相关的品牌、属性、分类的筛选功能在category.php和模板加上相应的功能即可
1、读出当前分类的所有下级分类,代码如下
$chlidren_category = $GLOBALS['db']->getALl('SELECT cat_id, cat_name FROM ' . $GLOBALS['ecs']->table('category') ." WHERE parent_id = '$cat_id' and is_show = 1");
$category_id_all = array('all'=>array('cat_id' => $cat_id, 'cat_name' => 'all category', 'show' => 1));
foreach ($chlidren_category as $key => $value)
{
    if ($value['cat_id'] == $cat_id)
    {
        $chlidren_category[$key]['show'] = 1;
		$category_id_all['show'] = 0;
		continue;
    }
    else $chlidren_category[$key]['show'] = 0;
}
$category_list = array_merge($category_id_all, $chlidren_category);
$smarty->assign('category_list_all', $category_list);
2、修改goods_list.lbi文件,<form method="GET" name="listform">下面加入循环出分类的模板代码
<!-- {foreach from=$category_list_all item=cat_list} -->
<a href="javascript:;" onClick="javascript:category_change({$cat_list.cat_id})">{$cat_list.cat_name}</a
<!-- {/foreach} -->
<input type="hidden" name="category" value="{$category}" />改为
<input type="hidden" id="category_id" name="category" value="{$category}" />

3、common.js中加入js脚本
function category_change(cat_id)
{
    document.getElementById('category_id').value = cat_id;
    setTimeout(doSubmit, 0);
    function doSubmit() {document.forms['listform'].submit();}
}

本文原创地址:https://www.ecshopok.com/article-774.html
版权所有 © 转载时必须以链接形式注明出处!

觉得本文对您有用,想收藏下来!方法很简单:请点击-〉
我们一直坚持白天工作、晚上熬夜更新资源,付出了巨大的精力和时间,其中的辛酸难以言述。

文章评论

暂无评论,来发表一个吧

发表 取消
充值有惊喜 ECSHOP插件网微信客服edait_cn