很多朋友在用Phpcms做站时,具体需要在列表页、首页调用文章列表调用文章的点击量和评论排行,那么怎么才能做到在Phpcms v9首页、频道页、列表页、推荐位等页面获取文章浏览量和评论统计呢?
原因起于phpcms官方默认的模版没有在列表页面调用过文章点击量和评论数量,而且文章的内页调用浏览量hit的方法不适用于列表页。
下面分享代码: 一、Phpcms列表页面取得文章点击量及评论数量:
{pc:content action="lists" catid="$catid" num="25" order="id DESC" page="$page" moreinfo="1"}
{loop $data $r}
{php $db = pc_base::load_model('hits_model'); $_r = $db->get_one(array('hitsid'=>'c-'.$modelid.'-'.$r[id])); $views = $_r[views]; }
{php $comment_tag = pc_base::load_app_class("comment_tag", "comment"); $comment_total = $comment_tag->count(array('commentid'=>'content_'.$catid.'-'.$r[id].'-'.$modelid));}
<li><span class="rt">{date('Y-m-d H:i:s',$r[inputtime])}</span>·<a href="{$r[url}" target="_blank"{title_style($r[style])}>{$r[title]}</a> 点击:{$views} 评论数:{if $comment_total}{$comment_total} {else}0{/if}</li>
{/loop}
{$pages}
{/pc}

 二、Phpcms频道页面取得文章点击量及评论数量:
{pc:content action="lists" catid="$v[catid]" num="5" order="id DESC"}
{loop $data $v}
{php $db = pc_base::load_model('hits_model'); $_r = $db->get_one(array('hitsid'=>'c-'.$modelid.'-'.$v[id])); $views = $_r[views]; }
{php $comment_tag = pc_base::load_app_class("comment_tag", "comment"); $comment_total = $comment_tag->count(array('commentid'=>'content_'.$v[catid].'-'.$v[id].'-'.$modelid));}
<li><a href="{$v[url]}" target="_blank"{title_style($v[style])}>{$v[title]}</a>点击:{$views}评论数:{if $comment_total}{$comment_total}{else}0{/if}</li>
{/loop}
{/pc}
 
 三、Phpcms首页面取得文章点击量及评论数量:
{pc:content action="lists" catid="$r[catid]" num="5" order="id DESC" return="info"}
{php $categorys = getcache('category_content_'.$siteid,'commons');}
<ul class="list lh24 f14">
{loop $info $v}
{php $category = $categorys[$v[catid]];}
{php $modelid = $category['modelid'];}
{php $db = pc_base::load_model('hits_model'); $_r = $db->get_one(array('hitsid'=>'c-'.$modelid.'-'.$v[id])); $views = $_r[views]; }
{php $comment_tag = pc_base::load_app_class("comment_tag", "comment"); $comment_total = $comment_tag->count(array('commentid'=>'content_'.$v[catid].'-'.$v[id].'-'.$modelid));}
<li>·<a href="{$v['url']}" target="_blank" title="{$v['title']}"{title_style($v[style])}>{str_cut($v['title'],40)}</a> 点击:{$views} 评论:{if $comment_total}{$comment_total}{else}0{/if}</li>
{/loop}
</ul>
{/pc}
 
 四、Phpcms推荐位取得文章点击量及评论数量:
{pc:content action="position" posid="2" order="listorder DESC" num="4"}
{php $categorys = getcache('category_content_'.$siteid,'commons');}
{loop $data $r}
{php $category = $categorys[$r[catid]];}
{php $modelid = $category['modelid'];}
{php $db = pc_base::load_model('hits_model'); $_r = $db->get_one(array('hitsid'=>'c-'.$modelid.'-'.$r[id])); $views = $_r[views]; }
{php $comment_tag = pc_base::load_app_class("comment_tag", "comment"); $comment_total = $comment_tag->count(array('commentid'=>'content_'.$r[catid].'-'.$r[id].'-'.$modelid));}
<h4 class="blue"><a href="{$r[url]}" title="{$r[title]}">{str_cut($r[title],36,'')}</a> 点击:{$views} 评论:{if $comment_total}{$comment_total}{else}0{/if}</h4>
<p>{if $n==1}<img src="{thumb($r[thumb],90,60)}" width="90" height="60"/>{/if}{str_cut($r[description],112)}</p>
<div class="bk20 hr"><hr /></div>
{/loop}
{/pc}
 

PHPCMS V9 栏目列表调用文章点击量及评论数量方法的更多相关文章

  1. phpcms v9栏目列表调用每一篇文章内容方法1

    我们先来看下默认栏目调用的代码: 复制代码代码如下:{pc:content action="lists" catid="$catid" num="25 ...

  2. phpcms v9栏目列表调用每一篇文章内容方法

    {pc:content action="lists" catid="$catid" num="25" order="id DESC ...

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

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

  4. phpcms v9使用GET调用指定id文章内容、页面数据方法

    不知道大家有没有相同的体会?在使用Phpcms V9建站调用数据的时候,基础的数据用默认的模板的调用语句就好了,但复杂不常见的数据怎么调用呢?我们技术可能会研究半天,怀着探索的精神不断尝试.孜孜不倦. ...

  5. phpcms V9 常用的调用标签

    本文介绍phpcms v9中模板标签使用说明. >>调用根目录下phpcms\template\content\header文件 {template "content" ...

  6. PHPCMS v9栏目添加字段及描述编辑器修改方法

    为PHPCMS v9栏目添加字段和把描述的textarea编辑器变成fceditor编辑器的方法.如下: 1. 添加数据库字段:description1,添加位置:v9_catetory表 2. 在c ...

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

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

  8. dede频道页实现三级栏目嵌套调用文章

      dede频道页实现三级栏目嵌套调用文章: //支持arclist标签开始--> $typeid = $row['id']; if((class_exists('PartView'))) { ...

  9. 如何让dedecms文章点击量增加一定的数值

    用dedecms建站都知道有一个文章点击量这个参数,我们可不可以用这个浏览量做些延伸扩展呢?比如加上一个固定值变成另外一个指标.很多朋友已经想到了,如下图,我们将本文浏览量286设为点击量,加上300 ...

随机推荐

  1. 【leetcode】Word Ladder II

      Word Ladder II Given two words (start and end), and a dictionary, find all shortest transformation ...

  2. Zlib 在windows上的编译

    1.下载http://www.zlib.net 下载,最新版本1.2.8 2.解压后,实际已提供了在vc下编译的工程,目录为:zlib-1.2.8\contrib\vstudio. 其中的zlibst ...

  3. Windows下给鼠标右键菜单添加获得完全控制权限的菜单项

    这段时间计算机C分区里多了很多无用的文件,而且不在同一个目录下,搜索出来删除的时候提示没有管理员权限,需要在右键属性里面修改,非常麻烦,于是查询了一下发现可以在文件右键菜单添加一个获取权限的菜单项,这 ...

  4. Delphi xe5 手机开发经验(新手级别)

    Delphi xe5 手机开发经验(新手级别) http://diybbs.zol.com.cn/1/34037_699.html http://www.delphitop.com/html/jiqi ...

  5. ubuntu vsftp 安装

    1.输入sudo apt-get install vsftpd 回车 这样就安装完毕了,然后去建立一个ftp的帐号,我这里使用的是ftp. 2.输入useradd ftp 回车 输入密码 回车 这样帐 ...

  6. 【编程题目】n 个骰子的点数

    67.俩个闲玩娱乐(运算).2.n 个骰子的点数.把 n 个骰子扔在地上,所有骰子朝上一面的点数之和为 S.输入 n,打印出 S 的所有可能的值出现的概率. 思路:用递归把每个骰子的可能情况变量,记录 ...

  7. 使用WKWebView替换UIWebView

    开发App的过程中,常常会遇到在App内部加载网页,通常用UIWebView加载.这个自iOS2开始使用的网页加载器一直是开发的心病:加载速度慢,占用内存多,优化困难.如果加载网页多,还可能因为过量占 ...

  8. iOS-消息推送机制的实现

    OS消息推送的工作机制可以简单的用下图来概括: Provider是指某个iPhone软件的Push服务器,APNS是Apple Push Notification Service的缩写,是苹果的服务器 ...

  9. php面向对象:封装

    OOP三大特性:封装.继承.多态. 封装的目的:为了让类更安全封装的做法:1.类里面的成员变量做为private2.使用成员方法来间接访问成员变量3.在该方法里面加限制条件 注意:php类里面不允许出 ...

  10. Java Collection、Map集合总结

    1.Java中的Collection集合总结 Collection |---List(存储有序,可重复) |---ArrayList 底层数据结构是数组,查询快,增删慢. 线程不安全.效率高 |--- ...