最近在對自己做的小站的欄目進行擴展和細分,由原來的七個一級欄目變成十二個一級欄目,每個一級欄目再細分為四到八個二級欄目,以便更好的管理內容。但我遇到了一個問題,其中一個欄目我不想讓它在首頁的最新文章列表中顯示,按照織夢現有的辦法,就是在arclist標簽的typeid屬性里把想顯示文章的欄目ID全部設置上,但這樣做欄目ID太多了,以后維護起來也麻煩,于是我想既然arclist支持flag和noflag,那么應該也要支持typeid 和notypeid吧?經過一番測試,再跟蹤了一下源碼,發現織夢并不支持notypeid,那怎么辦?
打開/include/taglib/arclist.lib.php文件,找這段代碼(大概在130行):
1
2
3
4
5
6
7
8
9
|
return lib_arclistDone
(
$refObj, $ctag, $typeid, $ctag->GetAtt('row'), $ctag->GetAtt('col'), $titlelen, $infolen,
$ctag->GetAtt('imgwidth'), $ctag->GetAtt('imgheight'), $listtype, $orderby,
$ctag->GetAtt('keyword'), $innertext, $envs['aid'], $ctag->GetAtt('idlist'), $channelid,
$ctag->GetAtt('limit'), $flag,$ctag->GetAtt('orderway'), $ctag->GetAtt('subday'),
$ctag->GetAtt('noflag'),
$tagid,$pagesize,$isweight
);
|
在最后括號最后加上(注意前面的逗號):
1
|
,$ctag->GetAtt('notypeid')
|
然后再找到這一段代碼(大概在168行):
1
2
3
4
|
function lib_arclistDone(&$refObj, &$ctag, $typeid=0, $row=10, $col=1, $titlelen=30, $infolen=160,
$imgwidth=120, $imgheight=90, $listtype='all', $orderby='default', $keyword='',
$innertext='', $arcid=0, $idlist='', $channelid=0, $limit='', $att='', $order='desc', $subday=0,
$noflag='',$tagid='', $pagesize=0, $isweight='N')
|
在括號的最后加上(注意前面的逗號):
1
|
,$notypeid=0
|
最后再找到這一句:
1
|
$orwheres[] = ' arc.arcrank > -1 ';
|
在其前面增加以下代碼:
1
2
3
4
|
if(!empty($notypeid))
{
$orwheres[] = " and arc.typeid NOT IN (".GetSonIds($notypeid).")";
}
|
這樣,代碼就修改完畢了。保存之后就在arclist標簽里試試看notypeid屬性吧。對于網站欄目多,內容顯示時又錯綜復雜的情況,這樣的屬性還是蠻實用的。
調用方法:
1
|
{dede:arclist row=6 orderby=pubdate type='image.' imgwidth='108' imgheight='150' channelid='1' notypeid='9'}
|