英雄巴乔

博客园 首页 新随笔 联系 订阅 管理

phpcms get万能标签实现phpcms[上一篇][下一篇]文章的完美解决方案

把下列代码加入到show.html的相关位置:

   <ul>

       <li>
       {get sql='SELECT * FROM `phpcms_content` WHERE `contentid` > $contentid AND `catid` = $catid and status=99 order by contentid asc' return='r1' rows='1'}
        {php $front=1;}上一篇:<a href='{$r1[url]}'>{str_cut($r1[title], $titlelen)}</a>
        {/get}
        {if $front!=1}上一篇:没有了{/if}
        </li>
        <li>
        {get sql='SELECT * FROM `phpcms_content` WHERE `contentid` < $contentid AND `catid` = $catid and status=99 order by contentid desc' return='r2' rows='1'}
        {php $next=1;}下一篇:<a href='{$r2[url]}'>{str_cut($r2[title], $titlelen)}</a>
        {/get}
        {if $next!=1}下一篇:没有了{/if}
         </li>
   </ul>

posted on 2010-12-07 00:26  英雄巴乔  阅读(1023)  评论(0)    收藏  举报