dedecms增加php函數功能及在列表頁獲取當前欄目的文章數
打開include/common.func.php,在其中任一行(<?與?>的中間任一行)中加上如下函數.
function dynamic_num($current_id){global $dsql;$t_num = $dsql->GetOne("select count(*) as num from `dede_archives` where typeid='$current_id'");if(is_array($t_num)){ return "本欄目共有".$t_num[num]."篇文章";}else{ return "本欄目共有0篇文章" ;}}
在列表頁中這樣調用:{dede:type}[field:id function="dynamic_num(@me)" /]{/dede:type}
加入函數: