您现在的位置是:首页 > 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标签 

很赞哦! ()

相关源码

  • (PC+WAP)房屋建造建筑工程房地产建材行pbootcms网站模板下载本模板基于PbootCMS内核开发,为房屋建造、建筑工程及房地产建材类企业设计。通过本模板可快速搭建具有行业特色的企业官网,只需替换文字与图片内容即可适配其他行业使用。查看源码
  • 响应式粉色美容整形化妆品pbootcms网站模板开源源码该网站模板为美容整形、化妆品企业设计,采用响应式布局确保在手机、平板及PC端自动适配显示效果。基于PbootCMS内核开发,支持一键替换图文内容快速转换至其他行业应用。查看源码
  • (自适应)宽屏大气的净水器智能电子设备网站pbootcms源码下载本模板基于PbootCMS内核开发,为净水器设备、智能电子设备企业量身打造,采用响应式设计技术,可快速构建专业级企业官网。通过本模板可高效展示产品技术参数、解决方案及企业服务优势。查看源码
  • (自适应响应式)高端网站建设设计公司互联网营销网站pbootcms模板本模板基于PbootCMS内核开发,为网站建设公司和互联网营销企业量身打造。采用响应式设计,适配各种移动设备,提供统一的后台管理体验查看源码
  • (自适应响应式)HTML5建筑工程公司建筑集团网站模板下载基于PbootCMS内核开发的响应式建筑行业网站模板,为建筑工程公司、建筑集团等企业打造,通过简洁大气的设计风格展现企业专业形象。查看源码
  • 帝国CMS7.2互联网自媒体门户整站带数据源码免费下载分享一款高仿极客网门户模板,帝国cms7.2版本,非常适合互联网、自媒体、文章门户网站使用。测法发现备份数据恢复报错,找了几个版本的都是一样的,有能力的自行修复查看源码
分享笔记 (共有 篇笔记)
验证码: