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

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

{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里均可以):

    相关文章

    本教程操作系统:Windows10系统、phpcms 9版本、Dell G3电脑...
    PHPcms访问特点:单一入口模式。无论访问任何一个模块或者功...
    例如:{pc:contentaction="position"posid="...
    首先,上图之中的红色框框是没有的,我们想要给他加上,当然...
    头部<metaname="keywords"content="{$SEO...
    做网站时用的到的简单的栏目导航()phpcms多个栏目catidin(9,...