怎么让织梦artlist标签增加notypeid属性实现栏目过滤

来源:undefined 2025-01-04 00:00:30 1048

怎么让织梦artlist标签增加notypeid属性实现栏目过滤?

织梦的标签功能非常强大,只要熟悉这些标签,在前台调用各种形式的后台数据就能得心应手。当然,如果能懂点技术,对织梦的标签再加以改进,那就更完美了。

推荐学习:织梦cms

我最近在对自己小站的栏目进行扩展和细分,由原来的七个一级栏目变成十二个一级栏目,每个一级栏目再细分为四到八个二级栏目,以便更好的管理内容。

但我遇 到了一个问题,其中一个栏目我不想让它在首页的最新文章列表中显示,按照织梦现有的办法,就是在arclist标签的typeid属性里把想显示文章的栏目ID全部设置上,但这样做栏目ID太多了,以后维护起来也麻烦,于是我想既然arclist支持flag和noflag,那么应该也要支持typeid 和notypeid吧?

经过一番测试,再跟踪了一下源码,发现织梦并不支持notypeid,那怎么办?自己写吧!

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

1

2

3

4

5

6

7

8

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

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}

登录后复制

以上就是怎么让织梦artlist标签增加notypeid属性实现栏目过滤的详细内容,更多请关注php中文网其它相关文章!

最新文章