phpcms的一些标签用法

发布时间:2019-08-08

*文章点击量
phpcms文章点击量代码在(网站根目录/api/count.php)第50行,$views=$r['views']+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}

*列表页调用点击量

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

  点击:{$views}

 

*内容页调用点击量

    1.页面引入jquery

    2.把 <script  language="JavaScript" src="{APP_PATH}api.php?op=content&id={$id}&modelid={$modelid}" ></script> 放到页面底部,他返回的是  $('#todaydowns').html('8');$('#weekdowns').html('8');$('#monthdowns').html('8');$('#hits').html('8');   把放置点击量的容器 id 设置为其中的一个,比如



*根据点击量排行
{pc:get sql="select a.id,a.title,a.url,a.catid,b.hitsid,b.views from guo_news a left join guo_hits b on a.id=substring(b.hitsid,5) where a.catid in(10,11,12) order by b.views desc" num="4" cache="3600"}

views字段是总点击量,也有昨天点击量 :yesterdayviews ,天点击量:dayviews,周点击量:weekviews,月点击量:monthviews,