您现在的位置是:首页 > cms教程 > phpcms教程phpcms教程

phpcmsV9首页频道页列表页推荐位简单获取文章浏览量和评论统计的

龚韶釜2025-06-06phpcms教程已有人查阅

导读phpcmsV9首页频道页列表页推荐位简单获取文章浏览量和评论统计列表取得数据方法:频道页获取数据方法首页获取数据方法

phpcmsV9首页频道页列表页推荐位简单获取文章浏览量和评论统计
列表取得数据方法:
{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));}
<li><span class="rt">{date('Y-m-d H:i:s',$r[inputtime])}</span>·<a href="{$r[url]}" target="_blank"{title_style($r[style])}>{$r[title]}</a> 点击:{$views} 评论数:{if $comment_total}{$comment_total}{else}0{/if}</li>{/loop}
{$pages}
{/pc}
频道页获取数据方法
{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));}
<li><a href="{$v[url]}" target="_blank"{title_style($v[style])}>{$v[title]}</a>点击:{$views}评论数:{if $comment_total}{$comment_total}{else}0{/if}</li>
{/loop}
{/pc}
首页获取数据方法
{pc:content action="lists" catid="$r[catid]" num="5" order="id DESC" return="info"}
{php $categorys = getcache('category_content_'.$siteid,'commons');}
<ul class="list lh24 f14">
{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));}
<li>·<a href="{$v['url']}" target="_blank" title="{$v['title']}"{title_style($v[style])}>{str_cut($v['title'],40)}</a> 点击:{$views} 评论:{if $comment_total}{$comment_total}{else}0{/if}</li>
{/loop}
</ul>
{/pc}
推荐位获取数据方法
{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));}
<h4 class="blue"><a href="{$r[url]}" title="{$r[title]}">{str_cut($r[title],36,'')}</a> 点击:{$views} 评论:{if $comment_total}{$comment_total}{else}0{/if}</h4>
<p>{if $n==1}<img src="{thumb($r[thumb],90,60)}" width="90" height="60"/>{/if}{str_cut($r[description],112)}</p>
<div class="bk20 hr"><hr /></div>
{/loop}
{/pc}

本文标签:

很赞哦! ()

相关源码

  • (自适应)证书授权书防伪查询系统pbootcms模板本模板基于PbootCMS系统开发,为各类证书查询机构设计,可快速构建高效安全的证书核验平台。采用响应式布局技术,自动适配手机端操作,支持批量导入证书数据,提供便捷的查询接口,满足机构证书管理及用户在线核验需求。查看源码
  • 帝国cms7.5品牌连锁店招商加盟商机网站模版源码本模板为招商加盟、创业投资、品牌连锁等商业领域设计,采用帝国CMS7.5内核构建,整体风格简洁大气,突出商业信任感与专业度,适合各类招商加盟项目展示、品牌连锁店宣传等商业应用场景。查看源码
  • (自适应HTML5)响应式智能设备人工智能机器pbootcms源码免费下载这款基于PbootCMS开发的网站模板为人工智能和智能设备行业设计,采用现代化科技风格,突出产品的智能特性和技术创新。模板架构合理,功能完善,能够有效展示各类智能产品的核心功能和解决方案。查看源码
  • 自适应电子科技类产品公司pbootcms网站模板基于PbootCMS内核开发,为电子科技类企业设计,适用于电子产品展示、企业官网等场景。该模板采用‌开源架构‌,用户可自由访问和修改源码,灵活适配各类行业需求,无需二次开发成本查看源码
  • (PC+WAP)蓝色电缆桥架五金钢结构机械PbootCMS模板下载采用PC与WAP双端适配设计,满足桌面设备和移动端访问需求。专注服务于电缆桥架、钢结构及五金机械制造领域,通过结构化布局展示产品特性与技术参数,后台数据一体化管理提升内容维护效率。查看源码
  • 帝国CMS游戏应用APP推广下载站模板免费下载本模板为移动应用推广、手机游戏推广行业设计,集成H5游戏平台与APP下载功能,支持PC端与移动端自适应访问。专注于为应用开发商、游戏发行商提供专业的线上推广展示平台。查看源码
分享笔记 (共有 篇笔记)
验证码:

本栏推荐