• 设为首页
  • 收藏本站
  • 积分充值
  • VIP赞助
  • 手机版
  • 微博
  • 微信
    微信公众号 添加方式:
    1:搜索微信号(888888
    2:扫描左侧二维码
  • 快捷导航
    福建二哥 门户 查看主题

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

    发布者: 网神之王 | 发布时间: 2025-7-24 16:04| 查看数: 81| 评论数: 0|帖子模式

    废话不多说,直接上代码
    一、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])}·[url=https://zhuji.jb51.net/{$r[url}]{$r[title]}[/url] 点击:{$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));}
    [url=https://zhuji.jb51.net/{$v}]{$v[title]}点击:{$views}评论数:{if $comment_total}{$comment_total}{else}0{/if}

    {/loop}
    {/pc} 
    三、Phpcms首页面取得文章点击量及评论数量:
     
    代码如下:

    {pc:content action="lists" catid="$r[catid]" num="5" order="id DESC" return="info"}
    {php $categorys = getcache('category_content_'.$siteid,'commons');}
    <ul>
    {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));}
    ·<a href="https://zhuji.jb51.net/{$v['url']}" target="_blank">代码如下:

    {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 = $_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));}
    [url=https://zhuji.jb51.net/{$r}]{str_cut($r[title],36,'')} 点击:{$views} 评论:{if $comment_total}{$comment_total}{else}0{/if}


    {if $n==1}
    [img=90,60]https://zhuji.jb51.net/{thumb($r[thumb],90,60)}[/img]
    {/if}{str_cut($r[description],112)}



    {/loop}
    {/pc}
    来源:互联网
    免责声明:如果侵犯了您的权益,请联系站长(1277306191@qq.com),我们会及时删除侵权内容,谢谢合作!

    最新评论

    浏览过的版块

    QQ Archiver 手机版 小黑屋 福建二哥 ( 闽ICP备2022004717号|闽公网安备35052402000345号 )

    Powered by Discuz! X3.5 © 2001-2023

    快速回复 返回顶部 返回列表