phpcms实现在首页列表页频道页调用评论数代码分享

所属分类: CMS教程 / phpcms 阅读数: 553
收藏 0 赞 0 分享

废话不多说,直接上代码
一、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修改lists标签(实现调用文章所属栏目及点击数)

pc程序默认首页是无法调用出文章的点击数,而调用文章所属的栏目名称也很复杂,需要先使用php语句进行数据缓存后才能调用。其实我们可以一步到位,自己添加函数来实现在首页/频道页/列表页调用文章点击数及文章所属栏目名称
收藏 0 赞 0 分享

phpcms V9 邮箱配置方法

phpcms自带邮箱系统,用来发送注册信息等内容,但QQ普通邮箱已经不支持此功能了。建议使用163邮箱
收藏 0 赞 0 分享

phpcms V9 全站文章点击排行榜标签

我们在做内容站的时候,经常需要使用到文章排行榜,但phpcms默认的pc调用标签是需要具体栏目ID的,那么如何调用全站文章的点击排行榜呢
收藏 0 赞 0 分享

Phpcms v9 整合Discuz! X2.5 和UCenter 1.6.0详细图文教程

很多站长利用Phpcms v9搭建主站,然后用Discuz! X2.5搭建网站的论坛,这样一个网站就会有两个用户中心,分别是Phpcms v9 的phpsso和Discuz! X2.5的 UCenter。这就需要将两款程序进行整合,从而达到同步注册、同步登录、同步退出的效果
收藏 0 赞 0 分享

解决phpcms V9整合discuz! X3.0后 在phpcms新注册用户需要在discuz激活的问题

这篇文章介绍了在phpcms新注册用户需要在discuz激活问题的解决方法,需要的朋友可以参考下
收藏 0 赞 0 分享

PHPCMS V9文章内容页点击量如何调用

内容页点击量该如何调用,想必有些朋友又要犯愁了,在PHPCMS V9中可以在show.html 模板中首先加载jquery.min.js 这个js ,之后加入下文代码即可,希望对大家有所帮助
收藏 0 赞 0 分享

Phpcms V9 所有的中文变量一览

中文变量的意思想必就不用多介绍了吧,还不知道的朋友可以看看下文,本文整理了Phpcms V9 所有的中文变量,希望大家在使用时可以用到
收藏 0 赞 0 分享

PHPCMS V9数据库配置文件database.php位置在哪

初次用PHPCMS V9的朋友可能找不到数据库配置文件,其实在官方的wiki中已经介绍了。那就是 caches\configs\database.php 文件,下面为大家介绍这个文件中相关值的具体修改方法
收藏 0 赞 0 分享

Phpcms V9列表分页自定义页码文字(改成中文)

一般列表分页的页码显示是英文的,而中文站希望页面和分页列表希望是中文的,另外有时候还需要自定义,这就涉及到Phpcms V9列表分页自定义页码文字,有此需求的朋友可以参考下本文
收藏 0 赞 0 分享

phpcms v9如何获取文章的当前栏目名称

获取当前栏目的名称在某些情况下,特别是做优化时,还是比较实用的,通过{$CATEGORYS[$catid][catname]} 显示当前栏目名称,感兴趣的朋友可以参考下
收藏 0 赞 0 分享
查看更多