在使用dedecms 做站点列表文章时,有时候需要展示当前栏目下面有多少文章等等。
如何在dedecms调用、首先打开/include/extend.func.php文件加入以下代码:

/**
* 统计栏目文章数
* @global type $dsql
* @param type $tid
* @return type
*/
function GetListCount($tid, $size = 10) {
global $dsql;
$sql = GetSonIds($tid);
$row = $dsql->GetOne("Select count(id) as count From dede_archives where typeid in({$sql})");
$count = intval($row['count'] / $size);
return "{$row['count']}条-{$count}页-每页$size";
}当然如上代码可以修改自己想要的返回方式。
在列表模板中只需要如下调用即可
{dede:field.typeid function="GetListCount(@me)" /}
关键字词:

