來源:天興工作室
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=按照瀏覽數量排序;