第一種:根據所在欄目ID自動判斷顯示所在欄目的文章數
(<span>[field:ID runphp='yes'] @me = GetTotalArc(@me);[/field:ID]</span>)
第二種:指定欄目ID
{dede:sql sql="SELECT count( ID ) AS c FROM dede_archives where typeid = 欄目id "} 本月更新:[field:c /]篇 {/dede:sql}
第三種:DedeCMS欄目文章數量統計調用,欄目名稱按照文章數量排列
{dede:sql sql='SELECT d.typename,d.id,count(da.id) as heji FROM dede_arctype d left join dede_archives da on da.typeid=d.id where d.reid=0 group by d.typename order by heji desc limit 0,8;'} <span
class="text_1"><span
class="count">[[field:heji/]篇]</span><a href="http://www.dedecmsmuban.com/plus/list.php?tid=[field:id/]"> [field:typename/]共投遞稿件</a></span><br /> {/dede:sql}
第四種:
修改include/common.func.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']; }
在htm 最下方添加:
{dede:channel type='top' row='8'}<LI>[field:typename/](<span>[field:ID runphp='yes'] @me = GetTotalArc(@me);[/field:ID]</span>)</LI>{/dede:channel}
如果想調用副欄目的數量 就是
//*****統計欄目文章數
function GetTotalArc($tid2){
global $dsql;
$sql = GetSonIds($tid2);
$row = $dsql->GetOne("Select count(id) as dd From dede_archives where typeid2 in({$sql})");
return $row['dd']; }
HTM頁面不變
現在我們來說說動態調用欄目文章數:
動態調用主要針對當前列表頁的欄目,而當前的欄目是動態的,因此可以利用type標簽調用一個函數就行了。
要調用函數就得增加函數,打開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}
{dede:sql sql="SELECT count( * ) AS c FROM cmsxx_archives WHERE pubdate > UNIX_TIMESTAMP( CURDATE( ) ) "}
<li class="count">今日更新:<span>[field:c/]</span> 篇</li>
{/dede:sql}
{dede:sql sql="Select count(ID) as c From cmsxx_archives WHERE FROM_UNIXTIME(pubdate,'%m')=month(curdate())"}
<li class="count">當月更新:<span>[field:c/]</span> 篇</li>
{/dede:sql}
{dede:sql sql="select count(*) as c from cmsxx_archives} <li class="count">共有文章:<span>[field:c/]</span> 篇</li>
{/dede:sql}
{dede:sql sql="select sum(click) as c from cmsxx_archives"} <li class="count">總共閱讀:<span>[field:c/]</span> 人次</li>
{/dede:sql}
{dede:sql sql="select count(mid) as c from cmsxx_member "}
<li class="count">共有會員:<span>[field:c/]</span> 名</li>
{/dede:sql}
還可以指定欄目ID,例如:
{dede:sql sql="select count(*) as c from cmsxx_archives where channel in(1,2,3,5,6,9)"}
<li class="count">共有文章:<span>[field:c/]</span> 篇</li>
{/dede:sql}
http://
*