ecshop调用指定分类ID的下级分类


ecshop调用指定分类ID的下级分类 - 临沂顺网科技 - 临沂网站建设
第一步:打开 lib_goods.php 最后加上以下函数
//调用商品分类指定分类下级分类
function get_parent_id_tree($parent_id)
{
    $three_c_arr = array();
    $sql = 'SELECT count(*) FROM ' . $GLOBALS['ecs']->table('category') . ' WHERE parent_id = ' . $parent_id . ' AND is_show = 1 ';
    if ($GLOBALS['db']->getOne($sql))
    {
        $child_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($child_sql);
        foreach ($res AS $row)
        {
            if ($row['is_show'])
            $three_c_arr[$row['cat_id']]['id']   = $row['cat_id'];
            $three_c_arr[$row['cat_id']]['name'] = $row['cat_name'];
            $three_c_arr[$row['cat_id']]['url'] = build_uri(‘category’, array(‘cid’ => $row['cat_id']), $row['cat_name']);
        }
    }
    return $three_c_arr;
}
第二步:声明后用$smarty调用,就是在 index.php 中加上下面一句(注意这里加的位置要找对大约117行左右都行):
$smarty->assign('thiscid6', get_parent_id_tree(6)); //调用父级分类6的下级分类
第三步:现在可以在 index.dwt 模板文件里开始调用了
<ul>
<!--{foreach from=$thiscid6 item=child6}-->
<li><a href="/category.php?id={$child6.id}">{$child6.name|escape:html}</a></li>
<!--{/foreach}-->
</ul>

本文转自:http://blog.sina.com.cn/s/blog_6be719560100z38i.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值