方法一:
在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=按照浏览数量排序;
方法二:
热门文章代码
{php} $HotOrder = array('log_ViewNums'=>'DESC'); $HotWhere = array(array('=','log_Status','0')); $HotArray = $zbp->GetArticleList(array('*'),$HotWhere,$HotOrder,array(6),''); {/php} {foreach $HotArray as $hotlist} <li class="clear"> <a href="{$hotlist.Url}" rel="bookmark" target="_blank"> <div class="thumbnail-wrap"> <img width="120" height="80" src="{twh_zimeitizixun_picurl($hotlist)}" alt="{$hotlist.Title}" /> </div> </a> <div class="entry-wrap"> <a href="{$hotlist.Url}" rel="bookmark" target="_blank">{$hotlist.Title}</a> <div class="entry-meta">{$hotlist.Time('Y-m-d H:i:s')}</div> </div> </li> {/foreach}