dedecms统计栏目文章数量实现代码修订版
作者:
以下的实现办法为修订的方法,可实现任意指定栏目的文章数量统计,包括最终列表栏目和含有子栏目的栏目。
修改include/inc_functions.php文件
function GetTotalArc($typeid){
$dsql = new DedeSql(false);
if(!empty($typeid))
{
$reids = explode(",",$typeid);
$ridnum = count($reids);
if($ridnum>1){
$tpsql = "";
for($i=0;$i<$ridnum;$i++){
if($tpsql=="") $tpsql .= " And (".TypeGetSunID($reids[$i],$dsql,'');
else $tpsql .= " Or ".TypeGetSunID($reids[$i],$dsql,'');
}
$tpsql .= ") ";
$orwhere .= $tpsql;
unset($tpsql);
}else{
$orwhere .= " And ".TypeGetSunID($typeid,$dsql,'');
}
unset($reids);
}
$row = $dsql->GetOne("Select count(ID) as dd From #@__archives where typeid>0 $orwhere");
return $row['dd'];
}
调用方法
[field:id function='GetTotalArc(@me)'/]
复制代码 代码如下:
function GetTotalArc($typeid){
$dsql = new DedeSql(false);
if(!empty($typeid))
{
$reids = explode(",",$typeid);
$ridnum = count($reids);
if($ridnum>1){
$tpsql = "";
for($i=0;$i<$ridnum;$i++){
if($tpsql=="") $tpsql .= " And (".TypeGetSunID($reids[$i],$dsql,'');
else $tpsql .= " Or ".TypeGetSunID($reids[$i],$dsql,'');
}
$tpsql .= ") ";
$orwhere .= $tpsql;
unset($tpsql);
}else{
$orwhere .= " And ".TypeGetSunID($typeid,$dsql,'');
}
unset($reids);
}
$row = $dsql->GetOne("Select count(ID) as dd From #@__archives where typeid>0 $orwhere");
return $row['dd'];
}
调用方法
复制代码 代码如下:
[field:id function='GetTotalArc(@me)'/]