織夢DEDECMS網(wǎng)站統(tǒng)計欄目文章數(shù)量的標(biāo)簽
時間: 2019-05-13 11:27
閱讀: 次
作者:素材無憂網(wǎng)
織夢DedeCMS網(wǎng)站統(tǒng)計欄目文章數(shù)量的標(biāo)簽:
第一種:根據(jù)所在欄目ID自動判斷顯示所在欄目的文章數(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)計調(diào)用,欄目名稱按照文章數(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)計欄目文章數(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)計欄目文章數(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頁面不變
現(xiàn)在我們來說說動態(tài)調(diào)用欄目文章數(shù):
動態(tài)調(diào)用主要針對當(dāng)前列表頁的欄目,而當(dāng)前的欄目是動態(tài)的,因此可以利用type標(biāo)簽調(diào)用一個函數(shù)就行了。
要調(diào)用函數(shù)就得增加函數(shù),打開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篇文章" }
}
在列表頁中這樣調(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">共有會員:<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}
標(biāo)簽: