大家好,今天有点闲,看很多朋友经常问PHPCMS v9 首页,列表页,内容页调用点击怎么弄,打算抽时间把代码全部归纳出来,以便大家日后使用,如下:

  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, 内容页调取点击量
  

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

  

  建议大家养成一个好习惯,收藏有用的代码,不仅是为了会,更能够提高仿站效率,再次感谢大家对仿站网的支持。
  文章链接:http://www.upxinyuan.com/wangzhanjiaocheng/302_1.html请勿转载  后果自负

04-21 08:29