帝国CMS灵动标签按照点击数实现天、周、月排行榜调用
帝国CMS灵动标签按照点击数实现天、周、月排行榜调用
方法1、显示一周内信息点击排行
[e:loop={"select * from {$dbtbpre}ecms_news where FROM_UNIXTIME(newstime)>SUBDATE(NOW(),INTERVAL 7 DAY) order by onclick desc limit 10",0,24,0}]
" target="_blank">=$bqr['title']?>
[/e:loop]
或者
[e:loop={"select * from {$dbtbpre}ecms_news where newstime>UNIX_TIMESTAMP()-86400*7 order by onclick desc limit 10",0,24,0}]
" target="_blank">=$bqr['title']?>
[/e:loop]
或
[e:loop={'news',10,18,0,'newstime>UNIX_TIMESTAMP()-86400*7','onclick desc'}]
" target="_blank">=$bqr[title]?>
[/e:loop]
newstime:文章发布时间
其中86400*7中的7表示天,如果是月就是30 年就是365
其排列方式:文章发布时间起统计
今天(24小时):newstime>UNIX_TIMESTAMP()-86400*1 必须是今天发布的文章
一周:newstime>UNIX_TIMESTAMP()-86400*7 必须是一周内发布的文章
举例:
昨天:
$beginYesterday=mktime(0,0,0,date('m'),date('d')-1,date('Y'));
$endYesterday=mktime(0,0,0,date('m'),date('d'),date('Y'))-1;
?>
[e:loop={"select * from [!db.pre!]ecms_news where newstime BETWEEN $beginYesterday and $endYesterday order by onclick desc limit 10",0,24,0}]
标题:" target="_blank">=$bqr[title]?>---点击:=$bqr[onclick]?>
[/e:loop]
----------------------------------------
今天:
[e:loop={'news',10,18,0,'newstime>UNIX_TIMESTAMP()-86400*1','onclick desc'}]
标题:" target="_blank">=$bqr[title]?>---点击:=$bqr[onclick]?>
[/e:loop]
----------------------------------------
一周:
[e:loop={'news',10,18,0,'newstime>UNIX_TIMESTAMP()-86400*7','onclick desc'}]
标题:" target="_blank">=$bqr[title]?>---点击:=$bqr[onclick]?>
[/e:loop]
----------------------------------------
一月:
[e:loop={'news',10,18,0,'newstime>UNIX_TIMESTAMP()-86400*30','onclick desc'}]
标题:" target="_blank">=$bqr[title]?>---点击:=$bqr[onclick]?>
[/e:loop]
----------------------------------------
三月:
[e:loop={'news',10,18,0,'newstime>UNIX_TIMESTAMP()-86400*90','onclick desc'}]
标题:" target="_blank">=$bqr[title]?>---点击:=$bqr[onclick]?>
[/e:loop]
----------------------------------------
一年:
[e:loop={'news',10,18,0,'newstime>UNIX_TIMESTAMP()-86400*365','onclick desc'}]
标题:" target="_blank">=$bqr[title]?>---点击:=$bqr[onclick]?>
[/e:loop]
----------------------------------------
全部:
[e:loop={'news',10,18,0,'','onclick desc'}]
标题:" target="_blank">=$bqr[title]?>---点击:=$bqr[onclick]?>
[/e:loop]
方法2、
昨天:
$beginYesterday=mktime(0,0,0,date('m'),date('d')-1,date('Y'));
$endYesterday=mktime(0,0,0,date('m'),date('d'),date('Y'))-1;
?>
[e:loop={"select * from [!db.pre!]ecms_news where newstime BETWEEN $beginYesterday and $endYesterday order by onclick desc limit 10",0,24,0}]
标题:" target="_blank">=$bqr[title]?>---点击:=$bqr[onclick]?>
[/e:loop]
注释:
//php获取今日开始时间戳和结束时间戳
$beginToday=mktime(0,0,0,date('m'),date('d'),date('Y'));
$endToday=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;
//php获取昨日起始时间戳和结束时间戳 (即:前一天)
$beginYesterday=mktime(0,0,0,date('m'),date('d')-1,date('Y'));
$endYesterday=mktime(0,0,0,date('m'),date('d'),date('Y'))-1;
//调取这两天(包括今天):(修改昨天)--date('d')-1:这两天 、date('d')-2:这三天、以此类推(注意:$beginYesterday、$endYesterday这两个未改动,还是沿用的昨天的名称)
$beginYesterday=mktime(0,0,0,date('m'),date('d')-1,date('Y'));
$endYesterday=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;
//调取前两天(修改昨天)--date('d')-2:前两天 、date('d')-3:前三天、以此类推(注意:$beginYesterday、$endYesterday这两个未改动,还是沿用的昨天的名称)
$beginYesterday=mktime(0,0,0,date('m'),date('d')-2,date('Y'));
$endYesterday=mktime(0,0,0,date('m'),date('d'),date('Y'))-1;
//php获取上周起始时间戳和结束时间戳
$beginLastweek=mktime(0,0,0,date('m'),date('d')-date('w')+1-7,date('Y'));
$endLastweek=mktime(23,59,59,date('m'),date('d')-date('w')+7-7,date('Y'));
//php获取本周起始时间戳和结束时间戳
$beginThisweek=mktime(0,0 ,0,date("m"),date("d")-date("w")+1,date("Y"));
$endThisweek=mktime(23,59,59,date("m"),date("d")-date("w")+7,date("Y"));
//php获取上月起始时间戳和结束时间戳
$beginLastmonth=mktime(0,0,0,date("m")-1,1,date("Y"))
$endLastmonth=mktime(23,59,59,date("m"),0,date("Y"))
//php获取本月起始时间戳和结束时间戳
$beginThismonth=mktime(0,0,0,date('m'),1,date('Y'));
$endThismonth=mktime(23,59,59,date('m'),date('t'),date('Y'))