联系电话:020-28187900

一周热门文章的调用

发表时间:2012-08-03 阅读: 2380

还是以例子的方式说明比较直观。

K9内容应用的一周热门文章的调用的标签如下:(其他应用的一周热门文章的标签也差不多,只是表名不同而已)

 {? $today=date('Ymd',TIME-86400*7); ?}
{@res.join table1='%s_content_hit' table2='%s_content' field='sum(t1.hit) hit' field2='title,url' on='id' where='t1.date>{$today} and t2.status=1' group='t1.id' order='hit desc,t2.id desc'}
{#foreach($res as $rs)}
<p><a href="{DIR}{$rs[url]}" title="{$rs[title] code='quote'}">{$rs[title]}</a><span>[{$rs[hit]}]</span></p>
{#endforeach}

一周的时间: {? $today=date('Ymd',TIME-86400*7); ?},因为表名table1是按日来统计访问量,所以我们得先计算出一周的时间

时间判断where:t1.date>{$today}

热门统计hit:field='sum(t1.hit) hit'

表名table1:s_content_hit,每日的日访问统计表

表名table2:s_content,内容应用的主内容表

转载请注明出处:唯众网络


相关教程 【更多】

唯众网络