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

教程大全 2026-01-08 05:30:59 浏览

废话不多说,直接上代码一、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));}
  • {date('Y-m-d H:i:s',$r[inputtime])}·{$r[title]} 点击:{$views} 评论数:{if $comment_total}{$comment_total} {else}0{/if}
  • {/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));}
  • {$v[title]}点击:{$views}评论数:{if $comment_total}{$comment_total}{else}0{/if}
  • {/loop}{/pc} phpcms实现在首页页频道页调用数代码分享

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

    代码如下:

    {pc:content action="lists" catid="$r[catid]" num="5" order="id DESC" return="info"}{php $categorys = getcache('category_content_'.$siteid,'commons');}
    本文版权声明本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,请联系本站客服,一经查实,本站将立刻删除。

    发表评论

    热门推荐