求助:怎么把二级分类的商品分类树category_tree.lbi改成3J分类的
2016-07-07 14:55 来源:www.chinab4c.com 作者:ecshop专家
| 下面是我现在的二级分类的商品分类树category_tree.lbi的代码,求高手给我修改成3J分类的商品分类树,先谢谢了。 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <div class="catehome" id="category_home"> <ul> <!--{foreach from=$categories item=cat}--> <li class="parentCat"> <a href="{$cat.url}" class="cateone">{$cat.name|escape:html}</a> <div class="catetwo"> <h4><a href="{$cat.url}">All Subcategories within {$cat.name|escape:html}</a><span class="cate_new"></span></h4> <!--{foreach from=$cat.cat_id item=child name=child_cat}--> {if $smarty.foreach.child_cat.index % 2 eq 0 || $smarty.foreach.child_cat.first} <dl> {/if} <dt><a href="{$child.url}">{$child.name|escape:html}</a></dt> {if $smarty.foreach.child_cat.index % 2 eq 1 || $smarty.foreach.child_cat.last} </dl> {/if} <!--{/foreach}--> </div> </li> <!--{/foreach}--> </ul> </div> | 
回答:
| 自己顶,在线等高手回复。 | 
| 改下程序 /** * 获得指定分类同级的所有分类以及该分类下的子分类 * * @accesspublic * @paraminteger$cat_id分类编号 * @returnarray */ function get_categories_tree($cat_id = 0) { if ($cat_id > 0) { $sql = 'SELECT parent_id FROM ' . $GLOBALS['pon']->table('category') . " WHERE cat_id = '$cat_id'"; $parent_id = $GLOBALS['db']->getOne($sql); } else { $parent_id = 0; } /* 判断当前分类中全是是否是底级分类, 如果是取出底级分类上级分类, 如果不是取当前分类及其下的子分类 */ $sql = 'SELECT count(*) FROM ' . $GLOBALS['pon']->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['pon']->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['pon']->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['pon']->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; } | 
| <!--{foreach from=$child.cat_id item=childer}--> <dd>  <a href="{$childer.url}">{$childer.name|escape:html}</a></dd> <!--{/foreach}--> | 
| 没错,好棒。 | 
 
        
					
						
					
					
						
                          
					
				 
      
      最近更新
常用插件
- ecshop二次商品订购人信息
                                  ecshop二次商品订购人信息填写插件,有时候给朋友送花,或者是送礼品的... 
- ecshop二次开发详细页面生
                                  插件介绍: ECSHOP系统,在很多时候,很多商品没有人购买,不但购买的人... 
- ecshop2.7.1打印发货单插件
                                  ecshop2.7.1打印发货单插件介绍:ecshop2.7.1和以前的ecshop版本不一样,ecs... 
- ecshop商品分类名称增加样
                                  ecshop插件介绍:本插件可以方便在后台管理,为ecshop商品分类名称增加样... 
- ecshop分类批量扩展插件
                                  ecshop分类批量扩展插件,这个插件是ecshop插件里面比较核心的插件。我们... 
ecshop热门问答
ecshop热门资料
          
               
            ecshop领货卡 
                
            ecshopunderstand 
                
            ecshop事宜 
                
            ecshopsince 
                
            ecshop承德 
                
            ecshop女性 
                
            ecshop监视器 
                
            ecshop我是医生 
                
            ecshop竞拍、当前页 
                
            ecshoppackage 
                
            ecshop圣诞程序 
                
            ecshop已注册 
                
            ecshopException 
                
            ecshop盗版软件 
                
            ecshop百度搜 
                
            ecshop商品规格 
                
            图片上传 
                
            ecshop杀毒软件 
                
            ecshop没有问题 
                
            ecshopxampp 
                
            ecshop想赚钱 
                
            ecshop几个问题 
                
            ecshop老板 
                
            ecshop失真 
                
            ecshop用户协议 
                
            ecshop衔接 
                
            dedecmsseo 
                
            ecshopunserialize 
                
            ecshopG1型 
                
            ecshop升级出错 
             
        
      


