zblog获取后台分类管理所有一级分类目录ID的代码

zblog教程 40

前面博客吧分享过通过$zbp->GetCategoryList获取zblog后台分类管理所有分类目录的代码,如果只想获取所有顶级分类目录也可以通过$zbp->GetCategoryList来获取,只需要在前者的代码上进行简单的调整即可实现。

函数代码如下:

1
2
3
4
5
6
7
8
9
10
function themeid_rootID(){
	global $zbp;
	$boke8RootID = [];
	$where = array(array('=','cate_ParentID',0));
	$categries = $zbp->GetCategoryList(null,$where,array('cate_Order'=>'ASC'),null,null);	
	foreach ($categries as $cate){	
		array_push($boke8RootID,$cate->ID);
	}
	return $boke8RootID;
}

把上面的函数添加到主题的include.php文件就可以调用了,返回的值是一个数组。

调用示例:
1
2
$getBoke8RootID = themeid_rootID();
print_r($getBoke8RootID);

GetCategoryList()函数位置:zb_system/function/lib/zblogphp.php

精品推荐: