{loop subcat(0,0,0,$siteid) $r}{/loop}

获取子栏目

  • @param $parentid 父级id
  • @param $type 栏目类型
  • @param $self 是否包含本身 0为不包含
  • @param $siteid 站点id

在PHPCMS中的函数定义代码如下

function subcat($parentid = NULL, $type = NULL,$self = '0', $siteid = '') {
        if (empty($siteid)) $siteid = get_siteid();
        $category = getcache('category_content_'.$siteid,'commons');
        foreach($category as $id=>$cat) {
                if($cat['siteid'] == $siteid && ($parentid === NULL || $cat['parentid'] == $parentid) && ($type === NULL || $cat['type'] == $type)) $subcat[$id] = $cat;
                if($self == 1 && $cat['catid'] == $parentid && !$cat['child'])  $subcat[$id] = $cat;
        }
        return $subcat;
}
版权声明:本文为李维亮博主的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://www.liweiliang.com/524.html

标签: none

评论已关闭