织梦dedecms如何调用当前栏目文章数?
织梦dedecms调用当前栏目文章数方法
做模板时,经常需要为每个栏目加上此栏目的文章数。和大家分享下实现的方法,此方法适合5.6及5.7、5.7sp1其它未测
推荐学习:dedecms教程
步骤/方法
修改include/common.func.php文件,在最后加以下代码:
//统计栏目文章数functionGetTotalArc($tid){global$dsql;$sql=GetSonIds($tid);$row=$dsql->GetOne("Selectcount(id)asddFromzmb_archiveswheretypeidin({$sql})");return$row['dd'];}//统计当前栏目信息数functiondynamic_num($current_id){global$dsql;//读取当前栏目的子ID$sql="SELECTidFROMzmb_arctypeWHEREid='$current_id'||topid='$current_id'";$dsql->SetQuery($sql);$dsql->Execute();while($row=$dsql->GetArray()){$arr[]=$row[id];}foreach($arras$key=>$value){$type.=$value.',';}$ty="".$type."0";//echo$ty;$t_num=$dsql->GetOne("selectcount(*)asnumfromzmb_archiveswheretypeidin($ty)");//echo$t_num[num];if(is_array($t_num)){return"".$t_num[num]."";}else{return"0";}}