文章介绍

 

在网站开发中,对内容管理系统(CMS)进行自定义修改以满足特定需求是非常常见的。本文将详细介绍如何通过修改DedeCMS的/include/taglib/arclist.lib.php文件来添加“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='', $pagesize=0, $isweight='N')

 

同样,在该函数参数列表的最后一个括号前添加逗号,并插入以下代码:

 


, $notypeid=0

 

最后,定位到以下代码行:

 


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

 

在其前面插入以下代码:

 


if (!empty($notypeid)) {
    $orwheres[] = " and arc.typeid NOT IN (" . GetSonIds($notypeid) . ")";
}

 

至此,代码修改完成。保存文件后,您可以在模板中使用 {dede:arclist} 标签时尝试新增的 notypeid 属性。

 

使用示例:

 


{dede:arclist row=6 orderby=pubdate type='image.' imgwidth='108' imgheight='150' channelid='1' notypeid='1'}

 

此功能特别适用于网站栏目较多且内容显示逻辑复杂的情况。通过设置 notypeid 属性,您可以轻松排除某些栏目的内容,使页面展示更加灵活和高效。