如何实现点击产品一级分类,产品分类树只显示点击一级分类和二级分类
2016-07-07 16:04 来源:www.chinab4c.com 作者:ecshop专家
如何实现点击产品一级分类,产品分类树只显示点击一级分类和二级分类,其他的一级分类和二级类别都不显示 |
回答:
So easy! 修改一下 lib_goods.php下get_categories_tree这个函数。对where做一下条件筛选。 |
如何实现点击产品一级分类,产品分类树只显示点击一级分类和二级分类,其他的一级分类和二级类别都不显示 So easy! 修改一下 lib_goods.php下get_categories_tree这个函数。对where做一下条件筛选。 请问如何修改where function get_categories_tree($cat_id = 0) { if ($cat_id > 0) { $sql = 'SELECT parent_id FROM ' . $GLOBALS['ecs']->table('category') . " WHERE cat_id = '$cat_id'"; $parent_id = $GLOBALS['db']->getOne($sql); } else { $parent_id = 0; } /* 判断当前分类中全是是否是底级分类, 如果是取出底级分类上级分类, 如果不是取当前分类及其下的子分类 */ $sql = 'SELECT count(*) FROM ' . $GLOBALS['ecs']->table('category') . " WHERE parent_id = '$parent_id' AND is_show = 1 "; if ($GLOBALS['db']->getOne($sql) || $parent_id == 0) { /* 获取当前分类及其子分类 */ $sql = 'SELECT cat_id,cat_name ,parent_id,is_show ' . 'FROM ' . $GLOBALS['ecs']->table('category') . "WHERE parent_id = '$parent_id' AND is_show = 1 ORDER BY sort_order ASC, cat_id ASC"; $res = $GLOBALS['db']->getAll($sql); foreach ($res AS $row) { if ($row['is_show']) { $cat_arr[$row['cat_id']]['id']= $row['cat_id']; $cat_arr[$row['cat_id']]['name'] = $row['cat_name']; $cat_arr[$row['cat_id']]['url']= build_uri('category', array('cid' => $row['cat_id']), $row['cat_name']); if (isset($row['cat_id']) != NULL) { $cat_arr[$row['cat_id']]['cat_id'] = get_child_tree($row['cat_id']); } } } } if(isset($cat_arr)) { return $cat_arr; } } function get_child_tree($tree_id = 0) { $three_arr = array(); $sql = 'SELECT count(*) FROM ' . $GLOBALS['ecs']->table('category') . " WHERE parent_id = '$tree_id' AND is_show = 1 "; if ($GLOBALS['db']->getOne($sql) || $tree_id == 0) { $child_sql = 'SELECT cat_id, cat_name, parent_id, is_show ' . 'FROM ' . $GLOBALS['ecs']->table('category') . "WHERE parent_id = '$tree_id' AND is_show = 1 ORDER BY sort_order ASC, cat_id ASC"; $res = $GLOBALS['db']->getAll($child_sql); foreach ($res AS $row) { if ($row['is_show']) $three_arr[$row['cat_id']]['id']= $row['cat_id']; $three_arr[$row['cat_id']]['name'] = $row['cat_name']; $three_arr[$row['cat_id']]['url']= build_uri('category', array('cid' => $row['cat_id']), $row['cat_name']); if (isset($row['cat_id']) != NULL) { $three_arr[$row['cat_id']]['cat_id'] = get_child_tree($row['cat_id']); } } } return $three_arr; } 帮帮忙 兄弟 帮我修改下原始代码都贴上了 谢谢啊 |
请问如何更改这段函数 我把函数贴出来 请高手帮忙改下 万分感谢 /** * 获得指定分类同级的所有分类以及该分类下的子分类 * * @accesspublic * @paraminteger$cat_id分类编号 * @returnarray */ function get_categories_tree($cat_id = 0) { if ($cat_id > 0) { $sql = 'SELECT parent_id FROM ' . $GLOBALS['ecs']->table('category') . " WHERE cat_id = '$cat_id'"; $parent_id = $GLOBALS['db']->getOne($sql); } else { $parent_id = 0; } /* 判断当前分类中全是是否是底级分类, 如果是取出底级分类上级分类, 如果不是取当前分类及其下的子分类 */ $sql = 'SELECT count(*) FROM ' . $GLOBALS['ecs']->table('category') . " WHERE parent_id = '$parent_id' AND is_show = 1 "; if ($GLOBALS['db']->getOne($sql) || $parent_id == 0) { /* 获取当前分类及其子分类 */ $sql = 'SELECT cat_id,cat_name ,parent_id,is_show ' . 'FROM ' . $GLOBALS['ecs']->table('category') . "WHERE parent_id = '$parent_id' AND is_show = 1 ORDER BY sort_order ASC, cat_id ASC"; $res = $GLOBALS['db']->getAll($sql); foreach ($res AS $row) { if ($row['is_show']) { $cat_arr[$row['cat_id']]['id']= $row['cat_id']; $cat_arr[$row['cat_id']]['name'] = $row['cat_name']; $cat_arr[$row['cat_id']]['url']= build_uri('category', array('cid' => $row['cat_id']), $row['cat_name']); if (isset($row['cat_id']) != NULL) { $cat_arr[$row['cat_id']]['cat_id'] = get_child_tree($row['cat_id']); } } } } if(isset($cat_arr)) { return $cat_arr; } } function get_child_tree($tree_id = 0) { $three_arr = array(); $sql = 'SELECT count(*) FROM ' . $GLOBALS['ecs']->table('category') . " WHERE parent_id = '$tree_id' AND is_show = 1 "; if ($GLOBALS['db']->getOne($sql) || $tree_id == 0) { $child_sql = 'SELECT cat_id, cat_name, parent_id, is_show ' . 'FROM ' . $GLOBALS['ecs']->table('category') . "WHERE parent_id = '$tree_id' AND is_show = 1 ORDER BY sort_order ASC, cat_id ASC"; $res = $GLOBALS['db']->getAll($child_sql); foreach ($res AS $row) { if ($row['is_show']) $three_arr[$row['cat_id']]['id']= $row['cat_id']; $three_arr[$row['cat_id']]['name'] = $row['cat_name']; $three_arr[$row['cat_id']]['url']= build_uri('category', array('cid' => $row['cat_id']), $row['cat_name']); if (isset($row['cat_id']) != NULL) { $three_arr[$row['cat_id']]['cat_id'] = get_child_tree($row['cat_id']); } } } return $three_arr; } |
最近更新
常用插件
- ecshop注册审核插件
ecshop插件介绍:ecshop会员注册审核插件,主要是在前台提供给注册的时候...
- ecshop虚拟发货插件
ecshop虚拟发货插件介绍: ecshop虚拟发货插件,主要为了通过后台手动录...
- ecshop的oss插件
ecshop的oss插件免费共享了,oss,ecshoposs...
- ecshop没登陆情况下订单查
ecshop没登陆情况下订单查询插件,主要是针对ecshop在没有登陆的情况下...
- ecshop订单聚合插件
ecshop订单聚合插件,主要是为了方便ecshop中订单产品到货情况的分析和...
ecshop热门问答
ecshop热门资料
ecshop在线电话
ecshopdir
ecshopauto
ecshopphp
ecshoplogo设计
ecshop商店设置
ecshop送货上门
ecshop质量
ecshopZend
ecshop重量
ecshop不同
ecshop缺货不能订购
ecshopinvaild
ecshop换页
ecshop机制
ecshop售完
ecshop打假
ecshop配送区域修改
ecshop去除
ecshop文章页面
报价单
ecshop使用者
ecshop无刷新提交
ecshop担保支付
ecshop放大
ecshop捆绑
ecshop首页产品数量
ecshop辽宁
ecshop首页错误
ecshop户外家具 网站美工