

很多時候想做個前臺文章整站統(tǒng)計數(shù)量。這里簡單的分享一個調(diào)用方法,后期看看是否加入到系統(tǒng)中去!
首先先打開
\application\common.php
文件。
找到 :
if (!function_exists('GetTotalArc'))
{
/**
* 統(tǒng)計欄目文章數(shù)
*/
function GetTotalArc($typeid = 0)
{
if (empty($typeid)) {
return 0;
} else {
$cache_key = md5("common-GetTotalArc-{$typeid}");
$count = cache($cache_key);
if (empty($count)) {
if(version_compare(getCmsVersion(),'v1.6.6','>')) {
$count = \think\Db::name('arctype')->where(['id'=>$typeid])->value('total_arc');
cache($cache_key, $count, null, 'arctype');
} else {
$row = model('Arctype')->getHasChildren($typeid);
if (empty($row)) return 0;
$typeids = array_keys($row);
$allow_release_channel = config('global.allow_release_channel');
$condition = [
'typeid' => ['IN', $typeids],
'channel' => ['IN', $allow_release_channel],
'arcrank' => ['gt', -1],
'status' => 1,
'is_del' => 0,
];
/*定時文檔顯示插件*/
if (is_dir('./weapp/TimingTask/')) {
$TimingTaskRow = model('Weapp')->getWeappList('TimingTask');
if (!empty($TimingTaskRow['status']) && 1 == $TimingTaskRow['status']) {
$condition['add_time'] = ['elt', getTime()]; // 只顯當天或之前的文檔
}
}
/*end*/
$count = \think\Db::name('archives')->where($condition)->count('aid');
cache($cache_key, $count, null, 'archives');
}
}
return intval($count);
}
}
}
4599行下面 添加以下代碼:
if (!function_exists('GetArcdocument'))
{
/**
* 統(tǒng)計所有文章數(shù)
*/
function GetArcdocument($aid = 0)
{
$arcdoc = Db::name('archives');
$total = $arcdoc->count();
echo $total;
}
}
--------------------------------------------------------------------------------------------------------------------------
$carcdoc['add_time'] = ['elt', getTime()];
$total = \think\Db::name('archives')->where($arcdoc)->count('aid');
上面的紅色部分依次按條件是可以修改為這段部分,比如以今日添加的時間為準,今天和過去的所有帖子。
這個是可以條件自己修改 具體按自己能力 賴的話 就上面的紅色部分 反正都是全部文章數(shù)量
前臺調(diào)用標簽為:{$eyou.field.total|GetArcdocument=###}
效果就是 實際的文檔數(shù)量。

教程就寫到這里 有需要的自己添加吧!