ecshop显示当前分类栏目下的栏目分类

2016-09-07 22:03 来源:www.chinab4c.com 作者:ecshop专家

 找到ecshop根目录下category.php文件 大概330行左右

 



// $smarty->assign('categories', get_categories_tree($cat_id)); // 分类树
$arr_categories_tree= get_categories_tree($cat_id);
$sql='SELECT count(*) FROM '.$ecs->table('category'." WHERE parent_id = '$cat_id' AND is_show = 1 ";
if($db->getOne($sql)){
$smarty->assign('categories',array($cat_id=>$arr_categories_tree[$cat_id])); // 分类树
}else{
$smarty->assign('categories',array($cat['parent_id']=>$arr_categories_tree[$cat['parent_id']])); // 分类树
}

 

然后再模板下面调用

 

                     <div >
                             <div>商品分类:</div>
                            <ul>
                            <div >
                            <!--{foreach from=$categories item=cat}-->
                            <!-- {if $cat.cat_id}-->
                            <!--{foreach from=$cat.cat_id item=child}-->
                                <li><a href="{$child.url}">{$child.name}</a></li>
                                <!--{/foreach}-->
                                <!-- {/if} -->
                                <!--{/foreach}-->
                                </div>
                            </ul>
                      </div>

chinab4c提供,转载请注明网址!

(责任编辑:chinab4c)