首先调用的标签代码如下:
{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 点击量排行调用方法的更多相关文章

  1. PHPCMS v9点击量增加值加大的方法

    PHPCMS v9点击量增加值加大的方法 在根目录/api 50行 $views = $r['views'] + 1; 修改数字1即可修改每次刷新页面点击量增加的数值.

  2. phpcms v9网站搬家更换域名的方法

    PHPCMS 是国内领先的网站管理系统,同时也是一个开源的PHP开发框架. 本文介绍phpcms v9网站搬家更换域名的方法. 1.在新的主机空间把phpcms安装好. 新安装的版本一定要和准备搬迁的 ...

  3. PHPCMS 按点击量排序

    {pc:content action="hits" catid="12" num="4" order="views DESC&qu ...

  4. phpcms文章点击量统计方法

    phpcms用户广大,很好用,很傻瓜.设计思路也很好,对cms的常见功能都有设计,可以作为自己开发的参考. 最近看了下phpcms的源码关于文章点击量统计的这块,自己记录下. 默认文章点击量显示的位置 ...

  5. phpcms v9 wap内容页内容显示方法

    phpcms v9的wap手机门户的问题解决 默认的{$content}标签假如内容页一开始输入的不是html代码的话会出现调用不出来的情况,这里用{$rs['content']} 来调用则可以解决问 ...

  6. phpcms v9全站点击量排行代码

    前台: <ul> {pc:content action="sitehits" siteid="1" num="10" order ...

  7. phpcms v9更改后台文章排序的方法

    后台文章排序怎么才可以按自己输入的数字排列?如按4,3,2,1,从大到小排列?实现方法如下: 修改文件: phpcms\modules\content 中的 content.php 代码如下: $da ...

  8. phpcms v9文章页调用点击量方法

    1.在页面加载" 2.调用统计点击的标签:: 3.最后,在写上这一句:" phpcms v9增加文章随机点击数的方法 找到文件count.php(网站根目录/api) 查找第50行 ...

  9. Phpcms v9 实现首页|列表页|内容页调用点击量的代码

    很多朋友经常问Phpcms v9的首页.列表页.内容页点击量如何调用.今天给大家分享phpcms V9如何分别在首页.列表页.内容页调用点击量代码 1,Phpcms v9首页调用点击量 {pc:con ...

随机推荐

  1. centos 6.5 apache配置web应用&防火墙设置(入门级)

    硬件:centos 6.5 服务器 , Dell R420 , 两个网口,一个给公网,一个给内网. 软件:apache 2.2 配置了virtualhost以后,用curl在本地可以访问.但是其他机器 ...

  2. OC block的简单使用

    http://blog.csdn.net/itpeng523/article/details/23965147 一.先用Xcode创建一个空工程 学习block之前先用弄懂c语言的函数指针 看代码: ...

  3. [20160725]MyComparableTest

    知识点: 1.Collections的使用. 2.自定义类泛型的使用. 3.自定义类,toString();equals();hashCode()方法的重写. import java.util.*; ...

  4. Binary Tree Vertical Order Traversal

    Given a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bott ...

  5. poj 2378 (dijkstra)

    http://poj.org/problem?id=2387 一个dijkstra的模板题 #include <stdio.h> #include <string.h> #de ...

  6. Javascript之setTimeout

    参考:http://codethoughts.info/javascript/2015/07/06/javascript-callbacks/

  7. Java for LeetCode 229 Majority Element II

    Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorit ...

  8. 【leetcode】 Search a 2D Matrix (easy)

    Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the follo ...

  9. 20145213 《Java程序设计》实验四 Android开发基础

    20145213 <Java程序设计>实验四 Android开发基础 说在前面的话 不同以往实验,对于这次实验具体内容我是比较茫然的.因为点我,打开实验四的链接居然能飘出一股熟悉的味道,这 ...

  10. Sql Server 保留几位小数的两种做法

    数据库里的 float momey 类型,都会精确到多位小数.但有时候 我们不需要那么精确,例如,只精确到两位有效数字. 1. 使用 Round() 函数,如 Round(@num,2)  参数 2 ...