建站软件 优化软件 编程软件 网页辅助 站群程序 网站程序 图像处理 资源教程 字体下载 推荐软件


您的位置:首页 > PHP学习 > phpcms v9 首页、列表页、内容页调用点击量的方法

phpcms v9 首页、列表页、内容页调用点击量的方法

时间:2017-12-26 14:45:19  来源:免费模板网 作者:风雪 阅读次数 tagsphpcms

1首页调用点击率的代码请看下面

{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}

2:列表页面调用点击数量

{php $db = pc_base::load_model(‘hits_model’); $_r = $db->get_one(array('hitsid’=>’c-’.$modelid.’-’.$r[id])); $views = $_r[views]; }

点击的变量是{$views}

3:详情页面调用点击,这个在默认的模板里面有,引入调用js文件

<script type="text/javascript" src="{JS_PATH}jquery.min.js"></script>
 <script language="JavaScript" src="{APP_PATH}api.php?op=count&id={$id}&modelid={$modelid}"></script>
 <span id="hits"></span>


本文地址:https://www.freemoban.com/php/2017/1226/2921.html

猜你喜欢
栏目推荐
模板推荐

Copyright:www.freemoban.com 免费模板网 All Rights Reserved 网站备案:辽ICP备19014872号-2   辽公网安备 21010602000376号  辽公网安备:42900402000182号

免责声明:本站部分资源来自互联网收集,版权归原创者所有,如果侵犯了你的权益,我们会及时删除侵权内容,联系QQ:1615187561 谢谢合作!