注意:dede_archives這是系統(tǒng)默認(rèn)的數(shù)據(jù)庫表,如果你修改過表前綴dede_,請(qǐng)自行更改表名。在以下示例的標(biāo)簽中,有一部分只寫出了SQL語句,具體的完整標(biāo)簽寫法請(qǐng)參考:織夢(mèng)SQL標(biāo)簽調(diào)用方法
共有文章:** 篇
{dede:sql sql="select count(ID) as c from dede_archives where channel=1"}·共有文章:[field:c /]篇{/dede:sql} |
共有圖集:** 個(gè)
{dede:sql sql="select count(ID) as c from dede_archives where channel=2"}·共有圖集:[field:c /]個(gè){/dede:sql} |
共有軟件:** 個(gè)
{dede:sql sql="select count(ID) as c from dede_archives where channel=3"}·共有軟件:[field:c /]個(gè){/dede:sql} |
共有評(píng)論:**條
{dede:sql sql="select count(ID) as c from dede_feedback"}·共有評(píng)論:[field:c /]條{/dede:sql} |
共有會(huì)員:**名
{dede:sql sql="select count(ID) as c from dede_member "}共有會(huì)員:[field:c /]名{/dede:sql} {dede:sql sql="select count(mid) as c from dede_member "}共有會(huì)員:[field:c /] 名{/dede:sql} |
文章閱讀:** 人次
{dede:sql sql="select sum(click) as c from dede_archives"}文章閱讀:[field:c /]人次{/dede:sql} |
今日更新:**篇
{dede:sql sql="SELECT count( ID ) AS c FROM dede_archives WHERE pubdate > UNIX_TIMESTAMP( CURDATE( ) ) "}今日更新:[field:c /]篇{/dede:sql} |
24小時(shí)發(fā)布的新文章:
select count(id)+0 as total from dede_archives where UNIX_TIMES*****P() - pubdate < 86400 and arcrank >=0; //86400 是 3600 * 24,也就是24小時(shí)發(fā)布的新文章。 |
當(dāng)天發(fā)布的最新文章
SELECT count(ID) as count from dede_archives where pubdate > UNIX_TIMES*****P( FROM_UNIXTIME(UNIX_TIMES*****P(), '%Y-%m-%d 00:00:00')) limit 1; |
當(dāng)天審核通過的最新文章
SELECT count(ID) as count from dede_archives where pubdate > UNIX_TIMES*****P( FROM_UNIXTIME(UNIX_TIMES*****P(), '%Y-%m-%d 00:00:00')) and arcrank >0 limit 1; |
當(dāng)天審核通過的最新文章
where to_days(curdate())=to_days(from_unixtime(pubdate)) and arcrank=0 |
本月更新:**篇
{dede:sql sql="SELECT count( ID ) AS c FROM cn_archives WHERE FROM_UNIXTIME( pubdate, '%m' ) = month (curdate( )) "} ○ 本月更新:<strong>[field:c /]</strong> 篇;{/dede:sql} |
文章收藏次數(shù):
[field:ID runphp='yes']$dsql = new dedesql();$dsql -> SetQuery("select count(*) as c from cn_member_stow where aid=".@me);$nic_row = $dsql -> getone();@me=$nic_row['c'];[/field:ID] |
統(tǒng)計(jì)指定欄目及所有下屬分支欄目?jī)?nèi)的文章數(shù)
1、修改include/inc_functions.php文件,增加函數(shù)如下:
function GetTotalArc($tid){ $dsql = new DedeSql(false); $sql = TypeGetSunID($tid,$dsql); $row = $dsql->GetOne("Select count(ID) as dd From dede_archives where {$sql}"); return $row['dd']; } |
2、調(diào)用方法,在需要修改的模板頁插入如下代碼(其中的3是欄目ID,根據(jù)你的實(shí)際情況修改)
{dede:field function='GetTotalArc(3)'/} |
補(bǔ)充一點(diǎn):如果在欄目模板頁面上調(diào)用,可以用這個(gè)寫法,統(tǒng)計(jì)當(dāng)前欄目?jī)?nèi)的文章數(shù)
{dede:field name='ID' function='GetTotalArc(@me)'/} |
欄目文章統(tǒng)計(jì)功能,使用 dedecms 的runphp 接口 編寫一個(gè) 函數(shù)。利用channel標(biāo)簽的ID變量獲得函數(shù)。
function GetChannelArticleNum($id){ if(!$id || !is_numeric($id)) return 0; $dsql = new DedeSql(); require_once(dirname(__FILE__)。"/inc_channel_unit_functions.php"); $sql = TypeGetSunID($id,$dsql); $dsql -> SetQuery("Select count(*) as c From dede_archives where {$sql}"); $row = $dsql -> GetOne(); return $row['c']; } |
將該函數(shù)放入 inc_functions.php 中,示例調(diào)用方法:
{dede:channel type='top' row='8'} | [field:typename/] ([field:ID runphp='yes'] @me = GetChannelArticleNum(@me);[/field:ID]){/dede:channel} |
增加欄目文章統(tǒng)計(jì)功能
第一種方法:
修改include/inc_arcpart_view.php文件,找到function ParseTemplet()函數(shù),修改為:
function ParseTemplet() { if(!is_array($this->dtp->CTags)) return ""; foreach($this->dtp->CTags as $tagid=>$ctag) { $tagname = $ctag->GetName(); //countclass 統(tǒng)計(jì)欄目文章數(shù)量 if( $tagname == "countclass" ){ $tid = $ctag->GetAtt("typeid"); $row = $this->dsql->GetOne("Select count(ID) as dd From dede_archives where typeid='$tid' and arcrank<>-1"); $this->dtp->Assign($tagid,$row['dd']); } |
調(diào)用方法:{dede:countclass typeid='欄目編號(hào)'/}
第二種方法:
修改include/inc_functions.php文件,增加函數(shù)如下:
function GetTotalArc($tid){ $dsql = new DedeSql(false); $row = $dsql->GetOne("Select count(ID) as dd From dede_archives where typeid='$tid'"); return $row['dd']; } |
調(diào)用方法:[field:id function='GetTotalArc(@me)'/]
版權(quán)聲明: 本站資源均來自互聯(lián)網(wǎng)或會(huì)員發(fā)布,如果侵犯了您的權(quán)益請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)刪除!謝謝!
轉(zhuǎn)載請(qǐng)注明: dedecms萬能SQL標(biāo)簽使用方法大全