在phpcms v9中提供了直接调用文章点击量以及评论数是的方法,但只是在文章内容页里面有显示,其它页面均没有显示,但有时候我们是需要在v9首页、频道页、列表页以及其它页面显示文章点击以及评论数量的,这个时候再直接使用文章页面的调用方法就已经不适用了,下面是夏日博客从网上搜集过来的在各个页面调用文章点击以及评论数量的代码,在需要的页面进行直接调用即可,这里做个备注。,一、Phpcms列表页面取得文章点击量及评论数量:,二、Phpcms频道页面取得文章点击量及评论数量:,三、Phpcms首页面取得文章点击量及评论数量:,四、Phpcms推荐位取得文章点击量及评论数量:,

在phpcms v9中提供了直接调用文章点击量以及评论数是的方法,但只是在文章内容页里面有显示,其它页面均没有显示,但有时候我们是需要在v9首页、频道页、列表页以及其它页面显示文章点击以及评论数量的,这个时候再直接使用文章页面的调用方法就已经不适用了,下面是夏日博客从网上搜集过来的在各个页面调用文章点击以及评论数量的代码,在需要的页面进行直接调用即可,这里做个备注。

一、Phpcms列表页面取得文章点击量及评论数量:

  1. {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 = $_r18 views; } {php $comment_tag = pc_base::load_app_class("comment_tag""comment"); $comment_total = $comment_tag->count(array('commentid'=>'content_'.$catid.'-'.$r[id].'-'.$modelid));} class="rt">{date('Y-m-d H:i:s',$r[inputtime])}·"{$r[url]}" target="_blank"{title_style($r[style])}>{$r[title]} 点击:{$views} 评论数:{if $comment_total}{$comment_total}{else}0{/if}{/loop} {$pages} {/pc}  

二、Phpcms频道页面取得文章点击量及评论数量:

  1. {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 = $_r18 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));} "{$v[url]}" target="_blank"{title_style($v[style])}>{$v[title]}点击:{$views}评论数:{if $comment_total}{$comment_total}{else}0{/if} {/loop} {/pc}  

三、Phpcms首页面取得文章点击量及评论数量:

  1. {pc:content action="lists" catid="$r[catid]" num="5" order="id DESC" return="info"} {php $categorys = getcache('category_content_'.$siteid,'commons');} 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 = $_r18 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));} ·"{$v['url']}" target="_blank" title="{$v['title']}"{title_style($v[style])}>{str_cut($v['title'],40)} 点击:{$views} 评论:{if $comment_total}{$comment_total}{else}0{/if} {/loop}  {/pc}  

四、Phpcms推荐位取得文章点击量及评论数量:

  1. {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 = $_r18 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));} class="blue">"{$r[url]}" title="{$r[title]}">{str_cut($r[title],36,'')} 点击:{$views} 评论:{if $comment_total}{$comment_total}{else}0{/if{if $n==1}"{thumb($r[thumb],90,60)}" width="90" height="60"/>{/if}{str_cut($r[description],112)} class="bk20 hr">
 {/loop} {/pc}  

,

在phpcms v9中提供了直接调用文章点击量以及评论数是的方法,但只是在文章内容页里面有显示,其它页面均没有显示,但有时候我们是需要在v9首页、频道页、列表页以及其它页面显示文章点击以及评论数量的,这个时候再直接使用文章页面的调用方法就已经不适用了,下面是夏日博客从网上搜集过来的在各个页面调用文章点击以及评论数量的代码,在需要的页面进行直接调用即可,这里做个备注。

一、Phpcms列表页面取得文章点击量及评论数量:

  1. {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 = $_r18 views; } {php $comment_tag = pc_base::load_app_class("comment_tag""comment"); $comment_total = $comment_tag->count(array('commentid'=>'content_'.$catid.'-'.$r[id].'-'.$modelid));} class="rt">{date('Y-m-d H:i:s',$r[inputtime])}·"{$r[url]}" target="_blank"{title_style($r[style])}>{$r[title]} 点击:{$views} 评论数:{if $comment_total}{$comment_total}{else}0{/if}{/loop} {$pages} {/pc}  

二、Phpcms频道页面取得文章点击量及评论数量:

  1. {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 = $_r18 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));} "{$v[url]}" target="_blank"{title_style($v[style])}>{$v[title]}点击:{$views}评论数:{if $comment_total}{$comment_total}{else}0{/if} {/loop} {/pc}  

三、Phpcms首页面取得文章点击量及评论数量:

  1. {pc:content action="lists" catid="$r[catid]" num="5" order="id DESC" return="info"} {php $categorys = getcache('category_content_'.$siteid,'commons');} 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 = $_r18 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));} ·"{$v['url']}" target="_blank" title="{$v['title']}"{title_style($v[style])}>{str_cut($v['title'],40)} 点击:{$views} 评论:{if $comment_total}{$comment_total}{else}0{/if} {/loop}  {/pc}  

四、Phpcms推荐位取得文章点击量及评论数量:

  1. {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 = $_r18 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));} class="blue">"{$r[url]}" title="{$r[title]}">{str_cut($r[title],36,'')} 点击:{$views} 评论:{if $comment_total}{$comment_total}{else}0{/if{if $n==1}"{thumb($r[thumb],90,60)}" width="90" height="60"/>{/if}{str_cut($r[description],112)} class="bk20 hr">
 {/loop} {/pc}