/**
* 获取指定栏目下面的文章数量
*
* @param string $id 栏目id
* @param string $addthis 是否包含子栏目
* @return string
*/
if ( ! function_exists('getTypeArcLength')) {
function getTypeArcLength($id,$addson=true) {
global $dsql;
if($addson) {
$types = GetSonIds($id);
$sql = "SELECT count(id) as len FROM idea_arctiny where typeid IN ($types)";
} else {
$sql = "SELECT count(id) as len FROM idea_arctiny where typeid = $id";
}
$arclen = $dsql->GetOne($sql);
return $arclen['len'];
}
}
调用当前栏目的文章数量:
{dede:field.id function="getTypeArcLength(@me,false)"/}
如果你需要针对特定类型的栏目(如ID为24的栏目)来获取其文章数量,可以这样写:
{dede:type typeid='24'}
[field:id function="getTypeArcLength(@me,false)"/]
{/dede:type}