PHPCMS V9 按浏览次数排行调用文章

发布时间:2020-06-25 18:00:54 作者:gutaotao1989
来源:网络 阅读:691

频道总排行调用方法

<div class="box">
    <h6 class="title-2">频道总排行</h6>
    {pc:get sql="select a.id,a.title,a.url,a.catid,b.hitsid,b.views from v9_news a left join v9_hits b on a.id=substring(b.hitsid,5) where a.catid in ($arrchildid) order by b.views desc" num="10" cache="3600"}
    <ul class="content digg">
        {loop $data $r}
            <li> <a href="{$r[url]}" title="{$r[title]}"  target="_blank">{str_cut($r[title],36,'...')}</a></li>
        {/loop}
    </ul>
    {/pc}
</div>

频道月排行调用方法

<div class="box">
    <h6 class="title-2">频道总排行</h6>
    {pc:get sql="select a.id,a.title,a.url,a.catid,b.hitsid,b.views from v9_news a left join v9_hits b on a.id=substring(b.hitsid,5) where a.catid in ($arrchildid) order by b.views desc" num="10" cache="3600"}
    <ul class="content digg">
        {loop $data $r}
            <li> <a href="{$r[url]}" title="{$r[title]}"  target="_blank">{str_cut($r[title],36,'...')}</a></li>
        {/loop}
    </ul>
    {/pc}
</div>

调用全站所有文章排行的方法:

<div class="idxTopApps contents">
<ul class="indexIcns">
{pc:get sql="SELECT a.id,a.url,a.thumb,a.status,b.hitsid,b.views FROM v9_download a, v9_hits b WHERE a.status=99 and a.id=substring(b.hitsid,5) ORDER BY b.views DESC" num="6"}
{loop $data $r}
<li><a href="{$r['url']}"><img src="{$r['thumb']}" /></a></li>
{/loop}
{/pc}
</ul>
</div>

可以看到“substring(b.hitsid,5)”是截取hitsid字段,从左往右数第5个字符串,即“c-2-5”从左往右数,1个“c”,1个“2”,2个“-”,第5个字符就是“5”,截取后只剩下了第2个“-”后的id,到达了最终提取id的目的。当然,其中我还加入了另一个条件“status=99”,这个表示已经审核通过的文章,这个可有可无。

推荐阅读:
  1. phpcms 调用多级栏目和多级栏目下的文章列表
  2. phpcms数据字典

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

phpcms

上一篇:CentOS 7配置+xcache, php module

下一篇:剑指offer:数组中重复的数字

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》