您现在的位置是:首页 > cms教程 > phpcms教程phpcms教程

PHPCMSV9点击量排行调用方法

严锋滕2025-05-29phpcms教程已有人查阅

导读另外我们还需要修改phpcms里模型代码以适用其上面的调用标签,打开 phpcms\modules\content\classes\content_tag.class.php 文件,在里面添加一个函数,

首先调用的标签代码如下:
{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=2 本月点击:monthviews、day=48。

本文标签:

很赞哦! ()

相关源码

  • (PC+WAP)货物运输快递物流汽车贸易pbootcms模板下载为货运代理、汽车贸易及快递企业设计的全终端适配网站系统,整合运单追踪与车辆展示核心功能模块原生开发的DIV+CSS架构,支持WebP图像压缩技术。查看源码
  • (自适应)黑色摄影作品工作室pbootcms模板网站源码下载为风景摄影、个人工作室打造的高端网站模板,基于PbootCMS开源内核开发,采用HTML5自适应架构,PC与移动端实时数据同步,适配各类拍摄作品展示需求。查看源码
  • (自适应)响应式文章博客互联网新闻pbootcms模板下载本模板基于PbootCMS开发,专为科技新闻、互联网资讯和文章博客类网站设计。采用响应式布局技术,确保在电脑、平板和手机上都能获得最佳浏览体验。适用于科技媒体、行业博客查看源码
  • (自适应)居家生活日用品纸盘纸盒纸杯卫生纸巾生产厂家pbootcms模板为纸品生产企业打造的现代化展示平台,自动适应各种设备屏幕,确保浏览体验一致,完善的SEO功能,提升网站曝光度,基于PbootCMS构建,源码开放可定制。查看源码
  • 响应式艺考培训学校机构pbootcms模板html5源码基于PbootCMS免费开源内核开发,为艺考培训学校与艺术机构设计,替换图文即可快速适配全行业需求。响应式布局兼容手机/PC端,数据实时同步,运维效率提升300%。查看源码
  • (自适应手机端)英文外贸电子产品通用pbootcms模板源码下载为电子产品外贸企业设计的响应式网站模板,采用PbootCMS开发内核,支持多语言展示。模板默认集成产品展示系统、询价表单模块和企业资质展示区,满足跨境贸易基础需求。整站采用模块化设计,便于扩展业务场景。查看源码
分享笔记 (共有 篇笔记)
验证码:

本栏推荐