因為有些主題的原因,一些新加欄目不能按照需求,在首頁調出部分串列資料,我們可以這樣做:
1.找到該主題的include.php檔案,在該檔案最后添加代碼如下:
注意:
San_Tiger_GetArticleCategorys函式名中,需要將 San_Tiger換成網站所正在用的主題名
function San_Tiger_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.在后臺主題編輯器,(如果沒有安裝主題編輯器,可以在服務器端找到該主題的index.php檔案),修改template/index.php檔案;
注意:使用foreach回圈陳述句,包含San_Tiger_GetArticleCategorys(資料條數,'欄目id1,欄目id2,欄目id3',true)進行參考,欄目id可以單個可以多個,

3.效果如圖:


轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/499028.html
標籤:PHP
