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

所属分类: CMS教程 / phpcms 阅读数: 541
收藏 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 定时发布文章的实现方法

今天和大家分享下 PHPCMS V9 文章定时发布的方法,定时发布文章可以做到预约发布、自动发布,方便我们在忙的时候更新文章,保证搜索引擎的收录
收藏 0 赞 0 分享

phpcms v9站内外搜索代码分享

站内外搜索对一个网站有很重要的意义,接下来为大家介绍下phpcms v9实现站内外搜索的代码,感兴趣的朋友可以参考下哈
收藏 0 赞 0 分享

Phpcms v9 栏目列表选择性调用数据具体方法

在PC v9栏目列表中调用出了指定文章的内容,今天介绍下在栏目数据调用中从指定行数开始,比如从第2条或第N条开始调用,感兴趣的朋友可以参考下
收藏 0 赞 0 分享

PHPCMS V9 Ckeditor编辑器添加排版功能实现介绍

v9使用的Ckeditor编辑器,在使用过程中有些不尽人意的地方,接下来为大家介绍下我,改动几个地方,让Ckeditor编辑更加实用一些,感兴趣的朋友可以参考下哈,希望可以帮助到你
收藏 0 赞 0 分享

PHPCMS V9评论模块伪静态与TAG模块伪静态设置

本文为大家介绍下PHPCMS V9评论模块伪静态与TAG模块伪静态设置,感兴趣的朋友可以参考下哈,希望对你学习PHPCMS V9有所帮助
收藏 0 赞 0 分享

phpcms 的sso通信失败的解决和思路

朋友的phpcms 在sso 登陆设置中,出现通信失败,最终调试发现,服务器本机linux,无法访问本身域名的ip
收藏 0 赞 0 分享

关于phpcms2008 内部递增标变量 $n 使用时的注意事项

有一个递增的内部变量 $n,它是从1开始逐渐递增的,如果{$n}则表示具体的值,下面为大家介绍下关于phpcms2008 内部递增标变量 $n 的注意事项
收藏 0 赞 0 分享

PHPCMS V9跨站调用推荐位出现URL连接为空问题的解决方法

如果你在使用PHPCMS V9的时候需要在不同的站点之间调用推荐位可能会出现链接的URL为空的情况,下面是具体的解决方法,有类似问题的朋友可以参考下哈
收藏 0 赞 0 分享

Phpcms V9网站从本地上传到服务器需要修改的地方小结

网站在本地做好后要迁移到服务器上;网站在发展的过程中,很可能多次的修改域名。那么在Phpcms V9中我们要怎么进行设置呢
收藏 0 赞 0 分享

phpcms 读不到缓存 页面空白的解决方法

网站在服务器上运行正常,弄到我电脑上进入网站后台,更新缓存页面空白,访问首页还是空白。调试发现是在include/common.inc.php中执行到下面不执行了
收藏 0 赞 0 分享
查看更多