<?php $week = gmdate('w', TIME) - 1;
$week = $week != -1 ? $week : 6; $historytime = mktime(0, 0, 0, date('m', TIME), date('d', TIME) - $week, date('Y', TIME)); ?>
{get sql="select p.*,t.* from phpcms_content p,phpcms_content_count t where p.contentid=t.contentid and p.status=99 and p.inputtime>=$historytime order by t.hits desc" rows="10" return="v"}
标题及链接:<a herf="{$v[url]}" >{$v[title]}</a>点击数:{$v[hits]}
{/get}
本月帖子点击排行调用方法:
{php $historytime = mktime(0, 0, 0, date('m', TIME), 1, date('Y', TIME));}
{get sql="select p.*,t.* from phpcms_content p,phpcms_content_count t where p.contentid=t.contentid and p.status=99 and p.inputtime>=$historytime order by t.hits desc" rows="10" return="v"}
标题及链接:<a herf="{$v[url]}" >{$v[title]}</a>点击数:{$v[hits]}
{/get}
以上代码当然可以自定义,48小时点击:dayviews、day=2 本月点击:monthviews、day=48。
另外,有很多朋友碰到Phpcms V9无法调用catid的栏目分类的问题,在用到日发帖及点击排行的时候出错,当前可以用这个方法来解决:
<ul class="list eiss date">
{pc:get sql="SELECT * FROM `v9_news` a, `v9_hits` p WHERE a.catid=$catid and a.status=99 and a.inputtime > UNIX_TIMESTAMP()-7*3600*24 and CONCAT( 'c-1-', a.id ) = p.hitsid ORDER BY p.weekviews DESC" num="15"}
{loop $data $r}
<li><font title= "{date('Y-m-d', $r[inputtime])}"> {date('d', $r[inputtime])}日</font> <a href="{$r[url]}" target="_blank">{str_cut($r[title],38)}</a></li>
{/loop} {/pc}
</ul>
说明:方法如,当前是权宜之计,因为前缀以后可能会变.c-1 中的1应该是栏目编号. 官方的却一直是1。
点击加载更多