### 修改文件以支持 notypeid 属性 要实现 arclist 标签支持 notypeid 属性,我们需要对 Dedecms 的核心文件进行修改。主要涉及的文件是 `/include/taglib/` 目录下的 `arclist.lib.php` 文件。
#### 第一步:修改函数返回值 首先,打开 `arclist.lib.php` 文件,搜索以下代码:
return lib_arclistDone(...);
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')
);
#### 第二步:更新函数定义 接下来,搜索 `function lib_arclistDone`,并在该函数的参数列表中添加 `$notypeid=0`。修改后的函数定义如下:
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) . ")";
}
### 使用方法 完成上述修改后,上传并覆盖原文件即可开始使用新的 notypeid 属性。以下是 arclist 标签的一个示例:
{dede:arclist row=6 orderby=pubdate notypeid='7,8,9'}
[field:title /]
{/dede:arclist}
### 总结 通过上述步骤,我们成功让 Dedecms 的 arclist 标签支持了 notypeid 属性。这种方法不仅简化了多栏目环境下的内容调用操作,还提高了开发效率。如果您正在管理一个栏目繁多的网站,这一功能将极大地方便您的日常维护工作。记得在修改核心文件前备份原始文件,以免出现问题时无法恢复。