站点介绍
制作zblog程序模版时,有些页面需要个性化调用多个分类文章列表,官方文档的zblog调用代码达不到要求,就从网上找了一段完美解决zblog程序调用多个分类文章列表的代码,根据需要把代码复制到zblog模板中使用。
function GetArticleCategorys($Rows,$CategoryID,$hassubcate){global $zbp;$ids = strpos($CategoryID,',') !== false ? explode(',',$CategoryID) : array($CategoryID);$wherearray=array();foreach ($ids as $cateid){if (!$hassubcate) {$wherearray[]=array('log_CateID',$cateid);}else{$wherearray[] = array('log_CateID', $cateid);foreach ($zbp->categorys[$cateid]->SubCategorys as $subcate) {$wherearray[] = array('log_CateID', $subcate->ID);}}}$where=array(array('array',$wherearray),array('=','log_Status','0'),);$order = array('log_PostTime'=>'DESC');$articles= $zbp->GetArticleList(array('*'),$where,$order,array($Rows),'');return $articles;} 使用方法,代码中的10为数量,1,2,3为分类id号。{foreach $array=Nobird_GetArticleCategorys(10,'1,2,3',true) as $related}<li><a href="https://lanye.org/danai/{$related.Url}" target="_blank">{$related.Title}</a></li>{/foreach}