温馨提示:这篇文章已超过1529天没有更新,请注意相关的内容是否还可用!
做zblog php版本的CMS企业模板,通过GetList函数调用指定分类文章时,发现调用结果只有指定ID分类的文章,该ID分类下的子分类文章没有显示在调用结果中,在zblog官方论坛咨询,管理员给出回复,是GetList函数参数没有设置完整(所以要仔细研究函数)。
1、加入代码
把下面代码加入主题插件引用文件include.php中:
function slsort($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;}
2、模板文件调用
在模板文件中调用以下代码即可:
{php}$flids = explode(',','1,2');{/php}
{foreach $flids as $flid}
{if isset($categorys[$flid])}
<a href="{$categorys[$flid].Url}" title="{$categorys[$flid].Name}">{$categorys[$flid].Name}</a>
{/if}
{foreach $array=slsort(8,$flid,true) as $related}
<a href="{$related.Url}" title="{$related.Title}">{strip_tags($related.Title)}</a></p>
{/foreach}
{/foreach}
其中的1,2为分类id,可使用后面主题设置参数$zbp->Config(‘qyblue’)->cpid;
8为显示的数量
文章版权声明:除非注明,否则均为崔牛网原创文章,转载或复制请以超链接形式并注明出处。
发表评论