{dede:sonchannel}
<a href='[field:typeurl/]'>[field:typename/]</a>
{/dede:sonchannel}
{dede:channel type='son' noself='yes'}
<li><a href=http://www.dede58.com/"[field:typelink/]">[field:typename/]</a></li>
{/dede:channel}
{dede:channel type='son' typeid=‘栏目ID’ noself='yes'}
<li><a href=http://www.dede58.com/"[field:typelink/]">[field:typename/]</a></li>
{/dede:channel}
在/include/common.func.php 或者 /include/extend.func.php最下方处添加以下代码:
/*
* @description DEDE不允许执行子查询,解决栏目下文章统计的问题
* @param $level 为真时查询所有子类目
* */
function getTotalArcByTid($tid, $level=TRUE) {
global $dsql;
$level==TRUE && $tid = GetSonTypeID($tid);
$sql = "SELECT count(id) as total from `dede_archives` where typeid in($tid)";
$result = $dsql->GetOne($sql);
return $result['total'];
}
/*
* 递归获取符合条件的子栏目
* @param $tid 栏目ID
* @return string
* */
function GetSonTypeID($tid)
{
global $dsql;
$dsql->SetQuery("Select id From `dede_arctype` where reid in($tid) And ishidden<>1 order by sortrank");
$dsql->Execute($tid);
$typeid = '';
while($row=$dsql->GetObject($tid))
{
$typeid .= "{$row->id},";
$typeid .= GetSonTypeID($row->id);
}
return trim($typeid,',');
}
然后用这个标签调用:任选其一
{dede:field.typeid function="getTotalArcByTid(@me)"/}
[field:typeid function="getTotalArcByTid(@me)"/]