zblog模板和程序默認(rèn)并不存在讓其中某些分類中的文章不在首頁最新文章列表中顯示的功能,而現(xiàn)在又有不少網(wǎng)站因?yàn)槟承┨囟ǖ脑颍幌胱屢恍┓诸愔械奈恼略谑醉撟钚挛恼铝斜碇谐霈F(xiàn)(如:文章會重復(fù)顯示,或部分分類中的文章并不主要,無需占用首頁那么重要的位置),那么如何解決呢?代碼應(yīng)該怎樣寫?
其實(shí),想要實(shí)現(xiàn)這個目的,是有兩種方法的,這里只給大家說一種,而另一種因?yàn)樘玪ow了,這里就不寫出來了!
1,我們要先在ZBLOG模板里掛載一個接口:Filter_Plugin_ViewList_Core
Add_Filter_Plugin('Filter_Plugin_ViewList_Core','themeolnews_Index_ViewList');2,完善這個接口中的themeolnews_Index_ViewList函數(shù)代碼
function themeolnews_Index_ViewList(&$type,&$page,&$category,&$author,&$datetime,&$tag,&$w,&$pagebar){
global $zbp;
if($type == 'index') {
$indexDelCateListIDStr=$zbp->Config('themeolnews')->indexDelCateListIDStr;//這是后臺主題配置中的分類ID列表,字符串的形式
$indexDelCateListIDArray = strpos($indexDelCateListIDStr,',') !== false ? explode(',',$indexDelCateListIDStr) : array($indexDelCateListIDStr);
foreach($indexDelCateListIDArray as $indexDelCateListID){
$w[]=array('<>','log_CateID',(int)$indexDelCateListID);
}
//其實(shí)從此往下的代碼不寫,我們的目的也實(shí)現(xiàn)了,但,這并不完美,我們還要重建分頁,因?yàn)檫^濾了分類,文章數(shù)量會發(fā)生變化
$pagebar = new Pagebar($zbp->option['ZC_INDEX_REGEX']);
$pagebar->PageCount = $zbp->displaycount;
$pagebar->PageNow = $page;
$pagebar->PageBarCount = $zbp->pagebarcount;
}
}到此,我們的zblog模板就可以實(shí)現(xiàn)在首頁最新文章列表中排除某(些)指定分類文章的目的了,大家只要熟悉ZBLOGPHP的接口,剩下的處理起來就簡單了!
游客
皖公網(wǎng)安備 34162202000270號