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

前端之家收集整理的这篇文章主要介绍了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里均可以):

    猜你在找的phpcms相关文章