PHPCMS V9 点击量排行调用方法
首先调用的标签代码如下:
{pc:content action=”sitehits” siteid=”4″ num=”10″ order=”views DESC” cache=”3600″}
{loop $data $r}
{$r[title]}
{/loop}
{/pc}
另外我们还需要修改 phpcms 里模型代码以适用其上面的调用标签,
打开 phpcms\modules\content\classes\content_tag.class.php 文件,在里面添加一个函数,
代码如下:
/**
* sitehits站点点击排行
* @param $data
*/
function sitehits($data){
if(emptyempty($data['siteid'])) return false;
$siteid = intval($data['siteid']);
$this->hits_db = pc_base::load_model('hits_model');
$category_content = getcache('category_content','commons');
$catid = '';
//获取站点下所有栏目ID
foreach($category_content as $key=>$val){
if($val==$siteid){
$catid .= $comma.$key;
$comma=',';
}
}
//获取点击排行
$r = $this->hits_db->select('catid in('.$catid.')','hitsid',$data['limit'],$data['order']);
$return = array();
$sitemodel_model_db = pc_base::load_model('sitemodel_model');
$this->db_config = pc_base::load_config('database');
$tablepre = $this->db_config['default']['tablepre'];
foreach($r as $key){
preg_match_all('/-(\d+)-/',$key['hitsid'],$modelid);
$id = substr($key['hitsid'],(strpos($key['hitsid'],'-',2)+1));
$tablename = $sitemodel_model_db->get_one(array('modelid' => $modelid[1][0]),'tablename');
$this->db->table_name = $tablepre.$tablename['tablename'];
$return[] = array_merge($return,$this->db->get_one(array('id' => $id)));
}
return $return;
}
OK,v9首页频道调用点击量排行文章就已经做完了,下面再分享一些其它的点击排行调用方法,都是一些较实用的代码。
当天帖子点击排行调用方法:
{php $historytime = mktime(0, 0, 0, date('m', TIME), date('d', TIME), date('Y', TIME));}
{get sql="select p.*,t.* from phpcms_content p,phpcms_content_count t where p.contentid=t.contentid and p.status=99 and p.inputtime>=$historytime order by t.hits desc" rows="10" return="v"}
标题及链接:<a herf="{$v[url]}" >{$v[title]}</a>点击数:{$v[hits]} {/get}
本周帖子点击排行调用方法:
<?php $week = gmdate('w', TIME) - 1;
$week = $week != -1 ? $week : 6; $historytime = mktime(0, 0, 0, date('m', TIME), date('d', TIME) - $week, date('Y', TIME)); ?>
{get sql="select p.*,t.* from phpcms_content p,phpcms_content_count t where p.contentid=t.contentid and p.status=99 and p.inputtime>=$historytime order by t.hits desc" rows="10" return="v"}
标题及链接:<a herf="{$v[url]}" >{$v[title]}</a>点击数:{$v[hits]}
{/get}
本月帖子点击排行调用方法:
{php $historytime = mktime(0, 0, 0, date('m', TIME), 1, date('Y', TIME));}
{get sql="select p.*,t.* from phpcms_content p,phpcms_content_count t where p.contentid=t.contentid and p.status=99 and p.inputtime>=$historytime order by t.hits desc" rows="10" return="v"}
标题及链接:<a herf="{$v[url]}" >{$v[title]}</a>点击数:{$v[hits]}
{/get}
以上代码当然可以自定义,48小时点击:dayviews、day= 本月点击:monthviews、day=。
PHPCMS V9 点击量排行调用方法的更多相关文章
- PHPCMS v9点击量增加值加大的方法
PHPCMS v9点击量增加值加大的方法 在根目录/api 50行 $views = $r['views'] + 1; 修改数字1即可修改每次刷新页面点击量增加的数值.
- phpcms v9网站搬家更换域名的方法
PHPCMS 是国内领先的网站管理系统,同时也是一个开源的PHP开发框架. 本文介绍phpcms v9网站搬家更换域名的方法. 1.在新的主机空间把phpcms安装好. 新安装的版本一定要和准备搬迁的 ...
- PHPCMS 按点击量排序
{pc:content action="hits" catid="12" num="4" order="views DESC&qu ...
- phpcms文章点击量统计方法
phpcms用户广大,很好用,很傻瓜.设计思路也很好,对cms的常见功能都有设计,可以作为自己开发的参考. 最近看了下phpcms的源码关于文章点击量统计的这块,自己记录下. 默认文章点击量显示的位置 ...
- phpcms v9 wap内容页内容显示方法
phpcms v9的wap手机门户的问题解决 默认的{$content}标签假如内容页一开始输入的不是html代码的话会出现调用不出来的情况,这里用{$rs['content']} 来调用则可以解决问 ...
- phpcms v9全站点击量排行代码
前台: <ul> {pc:content action="sitehits" siteid="1" num="10" order ...
- phpcms v9更改后台文章排序的方法
后台文章排序怎么才可以按自己输入的数字排列?如按4,3,2,1,从大到小排列?实现方法如下: 修改文件: phpcms\modules\content 中的 content.php 代码如下: $da ...
- phpcms v9文章页调用点击量方法
1.在页面加载" 2.调用统计点击的标签:: 3.最后,在写上这一句:" phpcms v9增加文章随机点击数的方法 找到文件count.php(网站根目录/api) 查找第50行 ...
- Phpcms v9 实现首页|列表页|内容页调用点击量的代码
很多朋友经常问Phpcms v9的首页.列表页.内容页点击量如何调用.今天给大家分享phpcms V9如何分别在首页.列表页.内容页调用点击量代码 1,Phpcms v9首页调用点击量 {pc:con ...
随机推荐
- [大坑]FFT学习
[大坑]FFT学习 Macros #define fon(i,s) for(int i=0;i<s; ++i) #define fone(i,s) for(int i=0;i<=s;++i ...
- 什么情况下可以不写PHP的结束标签“?>”
我们经常看到有些PHP文件中的代码是只有开始标签,而没有结束标签的,那么什么情况下可以不写这个结束标签,而什么情况下必须写?先来看2个例子: 下面的代码正常运行: <?php echo 1234 ...
- java servlet的工作原理
servlet本质上就是java类嘛.不过是有特殊规范的java类而已.下面就说一说为什么servlet要有特殊规范. 首先,考虑一下什么地方用servlet,WEB应用,而且是需要servlet容器 ...
- Find the Duplicate Number
Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), pro ...
- struts2 校验数据的有效性 2种方式
Struts2的数据校验: 数据的校验分为客户端校验和服务器端两种: 客户端校验:JS完成的校验.(为了提升用户体验.减少用户的输入错误) 服务器端校验:在后台的校验.(必须的.) 手动编码进行校验: ...
- DATEADD和DATEDIFF函数、其他日期处理方法 、已打开的端口、FORMAT函数
DATEADD和DATEDIFF函数.其他日期处理方法 .已打开的端口.FORMAT函数 DATEADD和DATEDIFF函数.其他日期处理方法 .已打开的端口.Format函数 KeyLife富翁笔 ...
- 一些笔试题(C/C++)
1.there are two variables, don't use if.. else or ?: or switch or other judgement statements,find ou ...
- js正则表达式替换空格
str.replace(/^\s+|\s+$/g, '') 解析: str:要替换的字符串 \s : 表示 space ,空格+: 一个或多个^: 开始,^\s,以空格开始$: 结束,\s$,以空 ...
- 【leetcode】Linked List Cycle II (middle)
Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Foll ...
- 中等难度SQL语句(存储过程,分页,拼接字段、游标,日期类型转换,动态行转列,视图)汇总
一.创建存储过程 if Exists(select name from sysobjects where NAME = 'sp1LoginUser' and type='P')drop procedu ...