phpcms v9调用文章模型点击量及评论数量的方法

1、首页调用文章模型点击量及评论数量

PHP $categorys = getcache('category_content_'.$siteid,'commons');}
    {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));}
  • 点击:{$views} 评论:{if $comment_total}{$comment_total}{else}0{/if}
  • {/loop}
{/pc}

2、列表页调用文章模型点击量及评论数量:

{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));}
  • 点击:{$views} 评论数:{if $comment_total}{$comment_total} {else}0{/if}
  • {/loop} {$pages} {/pc}

    3、频道页调用文章模型点击量及评论数量

    {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));}
    
  • 点击:{$views} 评论数:{if $comment_total}{$comment_total}{else}0{/if}
  • {/loop} {/pc}

    4、推荐位调用文章模型点击量及评论数量:

    {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));}
    
  • 点击:{$views} 评论:{if $comment_total}{$comment_total}{else}0{/if}
  • {/loop} {/pc}

    5、内容调用文章模型点击量:
    首先,引入如下js(head或body里均可以):

    相关文章

    PHP打印方法: {php print_r(变量);} {php print_r(变量);} <?php ...
    调用一级栏目名称跟二级栏目名称:
    phpcms如何修改图片水印呢1、首先准备一张水印图片,命名为mark png(名字随意),放到网站根目录statics ...
    就目前phpcms2008下PHPCMS绑定二级域名地址不正确问题分析,在生成栏目的url时有bug,如下所示:比如当栏...
    phpcms手机门户网站配置,利用开源PHPcms就可以完成一个手机网站的制作,非常方便,也很简单,值得大家...