# dedecms如何在栏目列表中添加统计文档数量调用标签

*Published:* 2023-10-25
*Author:* 客服001

#### 温馨提醒

如果文章内容或图片资源失效，请留言反馈，我们会及时处理，谢谢

本文最后更新于2023年10月25日，已超过 180天没有更新



打开include/extend.func.php文件，在最后一行?的上面添加以下内容：

```
function GetTotalArc($tid)
{
global $dsql;
$sql = GetSonIds($tid);
$row = $dsql->GetOne("Select count(id) as dd From dede_archives where typeid in({$sql})");
return $row['dd'];
}
```

示例代码：

```
function litimgurls($imgid=0)
{
   global $lit_imglist;
   $dsql = new DedeSql(false);
   //获取附加表
   $row = $dsql->GetOne("SELECT c.addtable FROM dede_archives AS a LEFT JOIN dede_channeltype AS c ON a.channel=c.id where a.id='$imgid'");
   $addtable = trim($row['addtable']);
   //获取图片附加表imgurls字段内容进行处理
   $row = $dsql->GetOne("Select imgurls From `$addtable` where aid='$imgid'");
   //调用inc_channel_unit.php中ChannelUnit类
   $ChannelUnit = new ChannelUnit(2,$imgid);
   //调用ChannelUnit类中GetlitImgLinks方法处理缩略图
   $lit_imglist = $ChannelUnit->GetlitImgLinks($row['imgurls']);
   //返回结果
   return $lit_imglist;
}

// 文档数量调用标签

function GetTotalArc($tid){
 global $dsql;
 $sql = GetSonIds($tid);
 $row = $dsql->GetOne("Select count(id) as dd From dede_archives where typeid in({$sql})");
 return $row['dd'];   
}   
?>
```

针对arclist与list模板代码的调用方法：

```
[field:ID function='GetTotalArc(@me)'/]
```

其它位置的使用代码的调用方法：

```
[field:ID runphp='yes'] @me = GetTotalArc(@me);[/field:ID]
```

运行之后的效果截图如下：

[![](https://www.xarjtc.com/wp-content/uploads/2023/10/1E3W5W952U0-2P26.jpg)](https://www.xarjtc.com/wp-content/uploads/2023/10/1E3W5W952U0-2P26.jpg)