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