織夢(mèng)網(wǎng)站欄目統(tǒng)計(jì)標(biāo)簽及文章數(shù)量統(tǒng)計(jì)標(biāo)簽的使用。在做博客站時(shí),經(jīng)常需要顯示欄目的文章數(shù)量,如下圖:
第一種:根據(jù)所在欄目ID自動(dòng)判斷顯示所在欄目的文章數(shù)
(<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欄目文章數(shù)量統(tǒng)計(jì)調(diào)用,欄目名稱(chēng)按照文章數(shù)量排列
{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
在最后加入代碼:
//*****統(tǒng)計(jì)欄目文章數(shù)
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}
如果想調(diào)用副欄目的數(shù)量 就是
//*****統(tǒng)計(jì)欄目文章數(shù)
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頁(yè)面不變
現(xiàn)在我們來(lái)說(shuō)說(shuō)動(dòng)態(tài)調(diào)用欄目文章數(shù):
動(dòng)態(tài)調(diào)用主要針對(duì)當(dāng)前列表頁(yè)的欄目,而當(dāng)前的欄目是動(dòng)態(tài)的,因此可以利用type標(biāo)簽調(diào)用一個(gè)函數(shù)就行了。
要調(diào)用函數(shù)就得增加函數(shù),打開(kāi)include/common.func.php,在其中任一行(<?與?>的中間任一行)中加上如下函數(shù)。
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篇文章" ;
}
}
在列表頁(yè)中這樣調(diào)用:
{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">當(dāng)月更新:<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">共有會(huì)員:<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}