

技术支持
DEDECMS 获取指定栏目下面的文章数量,可以写一个自己的小助手,然后再用function去调用 。
第一步:打开/include/helpers/channelunit.helper.php 在里面增加一个方法getTypeArcLength($id,$addson=true) 代码如下
/** * 获取指定栏目下面的文章数量 * * @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)"/}{dede:type typeid='24'}[field:id function="getTypeArcLength(@me,false)"/]{/dede:type}