此方法适合织梦dedecmsv5.6及以上版本,其它版本暂未测试,修改方法如下: dede - 598080707.net
打开 include/common.func.php文件,在这个php文件里的?>之前,加上以下代码:
function GetTotalArc($tid){ global $dsql; $sql = GetSonIds($tid); $row = $dsql->GetOne("Select count(id) as dd From dede_archives where typeid in({$sql})"); return $row['dd']; } //统计当前栏目信息数 function dynamic_num($current_id){ global $dsql; //读取当前栏目的子ID $sql = "SELECT id FROM `dede_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 `dede_archives` where typeid in($ty)"); //echo $t_num[num]; if(is_array($t_num)){ return " ".$t_num[num]." "; }else{ return "0" ; } } |
然后在列表模板里调用模板里的调用以下代码代码:
{dede:type}[field:id function="dynamic_num(@me)" /]{/dede:type} |
这样就修改完成了. DEDE教程 - 598080707.net
>>学织梦CMS,看DEDE教程,就上DEDE技术吧:http://598080707.net/1/