ECSHOP导航栏使用二级菜单显示并调用商品子分类
2016-06-13 13:05 来源:www.chinab4c.com 作者:ecshop专家
在includes/cls_template.php里顶部插入分类函数代码: //通过参数判断是否存在二级分类 function get_subcate_byurl($url) { $rs = strpos($url,"category"); if($rs!==false) { preg_match("/\d+/i",$url,$matches); $cid = $matches[0]; $cat_arr = array(); $sql = "select * from ".$GLOBALS['ecs']->table('category')." where parent_id=".$cid." and is_show=1 ORDER BY sort_order ASC, cat_id ASC"; $res = $GLOBALS['db']->getAll($sql); foreach($res as $idx => $row) { $cat_arr[$idx]['id'] = $row['cat_id']; $cat_arr[$idx]['name'] = $row['cat_name']; $cat_arr[$idx]['url'] = build_uri('category', array('cid' => $row['cat_id']), $row['cat_name']); $cat_arr[$idx]['children'] = get_clild_list($row['cat_id']); } return $cat_arr; } else { return false; } } function get_clild_list($pid) { //开始获取子分类 $sql_sub = "select * from ".$GLOBALS['ecs']->table('category')." where parent_id=".$pid." and is_show=1 "; $subres = $GLOBALS['db']->getAll($sql_sub); if($subres) { foreach ($subres as $sidx => $subrow) { $children[$sidx]['id']=$subrow['cat_id']; $children[$sidx]['name']=$subrow['cat_name']; $children[$sidx]['url']=build_uri('category', array('cid' => $subrow['cat_id']), $subrow['cat_name']); } } else { $children = null; } return $children; } 接下来呢,ecshop中的模板文件,也就是thems,找到你自己的模板文件夹,我就使用默认的说好了,打开themes\default\library\page_header.lbi文件 找到ecshop的导航条模板文件代码,也就是以下代码:
最近更新
常用插件
- ecshop供应商插件免费下载
ecshop供应商插件免费下载...
- ecshop按分类筛选销售排行
ecshop按分类筛选销售排行...
- ecshop二次开发售后维修卡
插件介绍: 本插件是用于专门从事电子,信息,软件等售后服务关键比...
- ecshop选择下单时间插件
ecshop选择下单时间插件主要是根据不同的下单配送要求,在ecshop购物车...
- ecshop快递发货单打印商品
ecshop快递发货单打印商品信息,大家都知道ecshop快递单打印的时候,只能...