来源:天兴工作室
1、在include.php中添加,注意修改主题id
function 主题ID_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;
}2、前台调用:
{foreach $array=主题ID_GetArticleCategorys(10,'1,2,3',true) as $related}
<li><a href="{$related.Url}" target="_blank">{$related.Title}</a></li>
{/foreach}3、判断按发布时间排序、浏览数、评论数排序
log_PostTime=按照时间排序; log_CommNums=按照评论数量排序; log_ViewNums=按照浏览数量排序;