本次帝國CMS統計專題信息數量教程主要講的是列表頁list.var的代碼寫法。其他標簽調用同理,只需要小改就可以了。
二次開發后大致效果如下圖
統計的當前專題的信息數量,并按時間分類統計了7天內收錄的信息和30天內收錄的專題信息。
首先我們來帝國CMS調用專題列表,新建一個自定義列表,代碼如下
統計記錄:
select count(*) as total from [!db.pre!]enewszt
查詢記錄:
select ztname as title,ztpath as newspath,ztimg as titlepic,intro as smalltext,ztpath as classid,onclick,ztid as id from [!db.pre!]enewszt
然后我們再來寫列表頁的模板,勾選“使用程序代碼”,代碼如下
$tiao=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsztinfo where ztid='$r[id]'"); $tj=$empire->fetch1("select newstime from {$dbtbpre}enewsztinfo where ztid='$r[id]'"); $tian=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsztinfo where ztid='$r[id]' and '$tj[newstime]'>UNIX_TIMESTAMP()-86400*7"); $yue=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsztinfo where ztid='$r[id]' and '$tj[newstime]'>UNIX_TIMESTAMP()-86400*30"); $listtemp='<li> <a href="/[!--classid--]"> <img src="[!--titlepic--]"> </a> <div class="txt"> <h4><a href="/[!--classid--]">[!--title--]</a></h4> <p><i><b>'.$tiao.'</b>個討論</i> <i><b>[!--onclick--]</b>個關注</i></p> <span>7天新增<b>'.$tian.'</b>個討論, 30天新增<b>'.$yue.'</b>個討論</span> </div> <a href="/[!--classid--]" class="add">+關注</a> </li>';
精準像素來為大家說下意思,第一段$tiao為統計當前專題的所有信息數量,$tj為查詢當前專題的newstime字段,$tian為統計ztid等于當前專題ID并時間等于7天的信息,$yue同理是統計的30天的信息。
新聞熱點
疑難解答