{
    分享网正式开通,我们为大家提供免费资源,欢迎大家踊跃投稿!

DedeCMS增加notypeid属性以实现过滤栏目

余斗最近在做一个网站的时候,因为要在首页调用全站最新栏目,所以在arclist标签中把typeid属性设置为rand,生成首页后,发现自己不想调用的栏目也被调用出来,如果要单独去掉这个栏目就要在typeid中把我想要的栏目id全部加上,这样就很麻烦。想到既然arclist支持flag和noflag,那么应该也要支持typeid 和notypeid吧?

经过一番测试,余斗再跟踪了一下源码,发现织梦并不支持notypeid,那怎么办?只有二次开发一下了,在搜索了一些教程后,余斗找到解决方法:

打开/include/taglib/arclist.lib.php文件,找这段代码(大概在130行):


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
          );
 

在最后括号最后加上(注意前面的逗号):


,$ctag->GetAtt('notypeid')
 

然后再找到这一段代码(大概在168行):


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='',
 

在括号的最后加上(注意前面的逗号)


,$notypeid=0
 

最后再找到这一句(大概在321行)


$orwheres[] = ' arc.arcrank > -1 ';
 

在其后面增加以下代码


if(!empty($notypeid))
{
        $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'}
 

如果要过滤多个栏目则可以这样:


{dede:arclist row=6 orderby=pubdate type='image.' imgwidth='108' imgheight='150' channelid='1' notypeid='9,10,11'}
 
套路很深,不支持下载!


米微资源分享网 , 版权所有丨本站资源仅限于学习研究,严禁从事商业或者非法活动!丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:DedeCMS增加notypeid属性以实现过滤栏目
喜欢 ()分享 (0)