DEDECMS 统计栏目的文档数量

修改 include/common.func.php文件,在最后加以下代码:


/*
 * 统计栏目的文档数量
 */
function GetTotalArc($tid){
global $dsql;
$sql = GetSonIds($tid);
$row = $dsql->GetOne("Select count(id) as dd From zy_archives where typeid in({$sql})");
return $row['dd'];
}
//统计当前栏目信息数
function dynamic_num($current_id){
global $dsql;
//读取当前栏目的子ID
$sql = "SELECT id FROM zy_arctype WHERE id='$current_id' || topid='$current_id'";
$dsql->SetQuery($sql);
$dsql->Execute();
while($row = $dsql->GetArray()){
$arr[]=$row[id];
}
foreach($arr as $key=>$value){
$type .= $value . ',';
}
$ty= "".$type."0";
//echo $ty;
$t_num = $dsql->GetOne("select count(*) as num from zy_archives where typeid in($ty)");
//echo $t_num[num];
if(is_array($t_num)){
return "".$t_num[num]."";
}else{
return "0" ;
}
}

调用代码:

{dede:channel type='son' }
  • [field:typename/]([field:ID runphp='yes'] @me = GetTotalArc(@me);[/field:ID])
  • {/dede:channel}
    {dede:channelartlist typeid='3' row='45'}
    
  • 第{dede:field name='sortrank'/}类--{dede:field name='typename'/}({dede:field name='id' function="dynamic_num(@me)"/})
  • {/dede:channelartlist}




    欢迎转载,原文地址:http://www.lrfun.com/html/technology/DEDECMS/2015/1113/90.html

    上一篇:织梦网站被黑
    下一篇:DEDECMS 分页—输入页数跳转