您现在的位置是:首页 > cms教程 > 帝国CMS教程帝国CMS教程

帝国CMS增加自定义标签每月月份文章数量统计

捷彦2023-01-02帝国CMS教程已有人查阅

导读兼容帝国原有的使用方式,即网站信息统计标签【总数据】的使用方式相同,但时间为0永远无限,1为今天,2为本月,3为本每年(11表示今年1月,12表示今年2月,...,22表示今年12月),注意不能用4-10,否则会出错。 22以上的数字不计入,即全部为0

兼容帝国原有的使用方式,即网站信息统计标签【总数据】的使用方式相同,但时间为0永远无限,1为今天,2为本月,3为本每年(11表示今年1月,12表示今年2月,...,22表示今年12月),注意不能用4-10,否则会出错。 22以上的数字不计入,即全部为0

1、把下面的代码复制粘帖到eclassuserfun.php中<?php和?>间
//---------------------------自定义一个统计标签,兼容帝国原来的使用方法
//修改后的信息统计。$day参数11表示本年1月,12表示本年二月,...,22表示本年12月
function user_TotalData1($classid,$enews=0,$day=0,$totaltype=0){
global $empire,$class_r,$class_zr,$dbtbpre,$fun_r,$class_tr;
if(empty($classid))
{
return "";
}
//统计类型
if($totaltype==1)//评论数
{
$totalfield='sum(plnum) as total';
}
elseif($totaltype==2)//点击数
{
$totalfield='sum(onclick) as total';
}
elseif($totaltype==3)//下载数
{
$totalfield='sum(totaldown) as total';
}
else//信息数
{
$totalfield='count(*) as total';
}
if($day)
{
if($day==1)//今日信息
{
$date=date("Y-m-d");
$starttime=$date." 00:00:01";
$endtime=$date." 23:59:59";
}
elseif($day==2)//本月信息
{
$date=date("Y-m");
$starttime=$date."-01 00:00:01";
$endtime=$date."-".date("t")." 23:59:59";
}
elseif($day==3)//本年信息
{
$date=date("Y");
$starttime=$date."-01-01 00:00:01";
$endtime=($date+1)."-01-01 00:00:01";
}
elseif($day>10)//本年某月信息
{
$yue=$day-10;
$date=date("Y");
$starttime=$date."-".$yue."-01 00:00:01";
if($yue==12){$endtime=$date."-".$yue."-31 23:59:59";}else{$endtime=$date."-".($yue+1)."-01 00:00:01";}
}
$and=" and newstime>=".to_time($starttime)." and newstime<=".to_time($endtime);
}
if($enews==1)//统计标题分类
{
if(empty($class_tr[$classid][tbname]))
{
echo $fun_r['BqErrorTtid']."=<b>".$classid."</b>".$fun_r['BqErrorNtb'];
return "";
}
$query="select ".$totalfield." from {$dbtbpre}ecms_".$class_tr[$classid][tbname]." where ttid='$classid'".$and;
}
elseif($enews==2)//统计数据表
{
$query="select ".$totalfield." from {$dbtbpre}ecms_".$classid.(empty($and)?'':' where '.substr($and,5));
}
else//统计栏目数据
{
if(empty($class_r[$classid][tbname]))
{
echo $fun_r['BqErrorCid']."=<b>".$classid."</b>".$fun_r['BqErrorNtb'];
return "";
}
if($class_r[$classid][islast])//终极栏目
{
$where="classid='$classid'";
}
else//大栏目
{
$where=ReturnClass($class_r[$classid][sonclass]);
}
$query="select ".$totalfield." from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where ".$where.$and;
}
$num=$empire->gettotal($query);
echo $num;
}
?>//---------------------------自定义一个统计标签,兼容帝国原来的使用方法
//修改后的信息统计。$day参数11表示本年1月,12表示本年二月,...,22表示本年12月
function user_TotalData1($classid,$enews=0,$day=0,$totaltype=0){
global $empire,$class_r,$class_zr,$dbtbpre,$fun_r,$class_tr;
if(empty($classid))
{
return "";
}
//统计类型
if($totaltype==1)//评论数
{
$totalfield='sum(plnum) as total';
}
elseif($totaltype==2)//点击数
{
$totalfield='sum(onclick) as total';
}
elseif($totaltype==3)//下载数
{
$totalfield='sum(totaldown) as total';
}
else//信息数
{
$totalfield='count(*) as total';
}
if($day)
{
if($day==1)//今日信息
{
$date=date("Y-m-d");
$starttime=$date." 00:00:01";
$endtime=$date." 23:59:59";
}
elseif($day==2)//本月信息
{
$date=date("Y-m");
$starttime=$date."-01 00:00:01";
$endtime=$date."-".date("t")." 23:59:59";
}
elseif($day==3)//本年信息
{
$date=date("Y");
$starttime=$date."-01-01 00:00:01";
$endtime=($date+1)."-01-01 00:00:01";
}
elseif($day>10)//本年某月信息
{
$yue=$day-10;
$date=date("Y");
$starttime=$date."-".$yue."-01 00:00:01";
if($yue==12){$endtime=$date."-".$yue."-31 23:59:59";}else{$endtime=$date."-".($yue+1)."-01 00:00:01";}
}
$and=" and newstime>=".to_time($starttime)." and newstime<=".to_time($endtime);
}
if($enews==1)//统计标题分类
{
if(empty($class_tr[$classid][tbname]))
{
echo $fun_r['BqErrorTtid']."=<b>".$classid."</b>".$fun_r['BqErrorNtb'];
return "";
}
$query="select ".$totalfield." from {$dbtbpre}ecms_".$class_tr[$classid][tbname]." where ttid='$classid'".$and;
}
elseif($enews==2)//统计数据表
{
$query="select ".$totalfield." from {$dbtbpre}ecms_".$classid.(empty($and)?'':' where '.substr($and,5));
}
else//统计栏目数据
{
if(empty($class_r[$classid][tbname]))
{
echo $fun_r['BqErrorCid']."=<b>".$classid."</b>".$fun_r['BqErrorNtb'];
return "";
}
if($class_r[$classid][islast])//终极栏目
{
$where="classid='$classid'";
}
else//大栏目
{
$where=ReturnClass($class_r[$classid][sonclass]);
}
$query="select ".$totalfield." from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where ".$where.$and;
}
$num=$empire->gettotal($query);
echo $num;
}
?>

2、新建标签代码

后台-模板-标签-标签管理-增加标签-增加内容如下:

标签名:每月信息统计
标签符号:TotalData1
所属类别:
函数名:user_TotalData1
标签格式:[totaldata]栏目ID,操作类型,时间范围,统计类型[/totaldata]
标签说明:

操作类型说明:
操作类型 内容
0 统计栏目数据
1 统计标题分类
2 统计数据表

时间范围:0为不限;1为今日;2为本月;3为本年。
统计类型:0为统计信息数;1为统计评论数;2为统计点击数;3为统计下载数。
如果操作类型是“统计数据表”,栏目ID='数据表名'

[totaldata]栏目ID,操作类型,时间范围,统计类型[/totaldata]
新闻统计
[totaldata]2,0,3,0[/totaldata]

本文标签:帝国cms标签 

很赞哦! ()

相关源码

  • (自适应)五金配件机械蓝色营销型pbootcms模板免费下载基于PbootCMS的工业配件展示系统,精简DIV+CSS架构确保响应速度,自适应设计呈现参数表格,支持后台实时更新产品规格、在线留言等内容。查看源码
  • 蓝色工业机械五金设备pbootcms模板源码下载(PC+WAP)为机械制造与五金设备企业设计的响应式网站模板,基于PbootCMS内核开发。采用蓝色工业风格强化行业属性,宽屏布局突出设备细节展示,支持PC与WAP端自适应查看源码
  • (自适应)绿色农业机械设备农场网站源码下载为现代农业机械领域打造的响应式网站模板,采用PbootCMS内核开发,数据实时同步后台管理。通过简洁大气的视觉设计,有效展示农机产品技术参数与应用场景,帮助客户快速建立专业数字化形象。查看源码
  • (PC+WAP)蓝色电缆桥架五金钢结构机械PbootCMS模板下载采用PC与WAP双端适配设计,满足桌面设备和移动端访问需求。专注服务于电缆桥架、钢结构及五金机械制造领域,通过结构化布局展示产品特性与技术参数,后台数据一体化管理提升内容维护效率。查看源码
  • (PC+WAP)蓝色公司注册财务会计公证律师网站源码下载本模板基于PbootCMS内核开发,为财务会计事务所、律师公证机构等专业服务机构打造。采用自适应设计,确保在各类设备上都能呈现专业视觉效果,帮助机构建立值得信赖的线上形象。查看源码
  • (自适应)幽默笑话脑筋急转弯搞笑趣图博客pbootcms模板下载本模板基于PbootCMS系统开发,专为幽默笑话、搞笑趣图类网站设计。采用轻松活泼的布局风格,突出娱乐内容分享特色,适合各类笑话、段子、搞笑图片等内容展示。查看源码
分享笔记 (共有 篇笔记)
验证码: