如题,我想在文章内容页面显示出该文章被点击的次数,网上查到的js方法没用,在不改动程序的前提下调用,按说v9应该有这个功能吧,求解。。。。
ããphpcms v9å¢å æç« éæºç¹å»æ°çæ¹æ³ï¼
ããæ¾å°æ件count.phpï¼ç½ç«æ ¹ç®å½/apiï¼
ããæ¥æ¾ç¬¬50è¡ï¼æ¾å°è¿æ®µä»£ç $views = $r['views'] + 1;è¿éç1æ¯é»è®¤çï¼è¡¨ç¤ºæ¯æµè§ä¸æ¬¡ï¼ç¹å»éå¢å ä¸æ¬¡ï¼å¯ä»¥ä¿®æ¹æèªå·±æ³è¦çä»»ææ°å
ããæè $views = $r['views'] + rand(10,100); éæºçå¢å 10å°100ä¹é´çä¸ä¸ªä»»æçæ´æ°ï¼
ãã1ï¼é¦é¡µè°ç¨ç¹å»é
ãã{pc:content action="lists" catid="$r[catid]" num="5" order="id DESC" return="info"}
ãã{php $categorys = getcache('category_content_'.$siteid,'commons');}
ãã
ãã{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));}
ãã
ãã·{str_cut($v['title'],40)} ç¹å»ï¼{$views} è¯è®ºï¼{if $comment_total}{$comment_total}{else}0{/if}
ãã{/loop}
ãã
ãã{/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">
ãã<\span id="hits"><\script language="JavaScript" src="{APP_PATH}api.php?op=count&id={$id}&modelid={$modelid}"><\/span>
ããæ¾å°æ件count.phpï¼ç½ç«æ ¹ç®å½/apiï¼
ããæ¥æ¾ç¬¬50è¡ï¼æ¾å°è¿æ®µä»£ç $views = $r['views'] + 1;è¿éç1æ¯é»è®¤çï¼è¡¨ç¤ºæ¯æµè§ä¸æ¬¡ï¼ç¹å»éå¢å ä¸æ¬¡ï¼å¯ä»¥ä¿®æ¹æèªå·±æ³è¦çä»»ææ°å
ããæè $views = $r['views'] + rand(10,100); éæºçå¢å 10å°100ä¹é´çä¸ä¸ªä»»æçæ´æ°ï¼
ãã1ï¼é¦é¡µè°ç¨ç¹å»é
ãã{pc:content action="lists" catid="$r[catid]" num="5" order="id DESC" return="info"}
ãã{php $categorys = getcache('category_content_'.$siteid,'commons');}
ãã
ãã{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));}
ãã
ãã·{str_cut($v['title'],40)} ç¹å»ï¼{$views} è¯è®ºï¼{if $comment_total}{$comment_total}{else}0{/if}
ãã{/loop}
ãã
ãã{/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">
ãã<\span id="hits"><\script language="JavaScript" src="{APP_PATH}api.php?op=count&id={$id}&modelid={$modelid}"><\/span>
温馨提示:答案为网友推荐,仅供参考
第1个回答 推荐于2017-11-26
点击:<span id="hits"></span>
<script language="JavaScript" src="{APP_PATH}api.php?op=count&id={$id}&modelid={$modelid}"></script>
这两个加到模板中,官方默认模版中就有本回答被提问者和网友采纳
<script language="JavaScript" src="{APP_PATH}api.php?op=count&id={$id}&modelid={$modelid}"></script>
这两个加到模板中,官方默认模版中就有本回答被提问者和网友采纳
第2个回答 2015-05-26
楼主你好
在你模板的点击量的对应位置加上:
<span id="hits"></span>另外注意还要在该模板中引入官方的统计JS,代码是:
<script language="JavaScript" src="{APP_PATH}api.php?op=count&id={$id}&modelid={$modelid}"></script>
这两者缺一不可。
希望可以帮到你。 林羽凡
第3个回答 2013-09-22
<script language="JavaScript" src="{APP_PATH}api.php?op=count&id={$id}&modelid={$modelid}"></script>