zblog程序调用多个分类文章列表方法
制作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}
- 版权申明:此文如未标注转载均为本站原创,自由转载请表明出处《蓝叶》。
- 本文网址:https://lanye.org/web/948.html
- 上篇文章:zblog程序获取当前分类的主分类url地址
- 下篇文章:阿里云centos系统yum源错误解决方法