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

所属分类: CMS教程 / phpcms 阅读数: 655
收藏 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安全检测api漏洞修改方法

为什么360总是提示Phpcms v9有api漏洞?今天在这里与大家探讨Phpcms V9安全检测api漏洞修改方法
收藏 0 赞 0 分享

phpcms自定义碎片插件之内容碎片标签模块使用方法

这篇文章主要介绍了phpcms自定义碎片插件之内容碎片标签模块使用方法,需要的朋友可以参考下
收藏 0 赞 0 分享

phpcms v9碎片管理及调用技巧分享

这篇文章主要介绍了phpcms v9碎片管理及调用技巧,需要的朋友可以参考下
收藏 0 赞 0 分享

phpcms v9更换模板的具体操作方法

这篇文章主要介绍了phpcms v9更换模板的具体操作方法,需要的朋友可以参考下
收藏 0 赞 0 分享

phpcms V9自定义评论字段UTF8_CMSYOU修正版

这篇文章主要介绍了phpcms V9自定义评论字段UTF8_CMSYOU修正版,需要的朋友可以参考下
收藏 0 赞 0 分享

phpcms v9使用GET调用指定id文章内容、页面数据方法(get标签什么方法)

这篇文章主要介绍了phpcms v9使用GET调用指定id文章内容、页面数据方法(get标签什么方法),需要的朋友可以参考下
收藏 0 赞 0 分享

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

怎么样在Phpcms V9栏目列表调用每一篇文章内容?在此,与大家分享这一方法。
收藏 0 赞 0 分享

phpcms v9后台登陆模板修改方法和程序版本更新提示修改方法

这篇文章主要介绍了phpcms v9后台登陆模板修改方法和程序版本更新提示修改方法,需要的朋友可以参考下
收藏 0 赞 0 分享
查看更多