上/下一篇文章用来引导用户更加快速地阅读本页面相关的信息,以提高用户的体验。常用于文章的内容页。
例子:
同一模型的上/下一篇文章,if语句判断【查看】上/下一篇文章不存在的时候,输出“没有了",如果不需要的话,可直接删去。
{@res.join table1='%s_content' table2='%s_content_categroy_bind' field1='title,url' on='id' where="t1.mid=1 and t1.status=1 and t1.id< {$info['id']}" order='t1.id desc' number='1'} {#if(!empty($res))} {#foreach($res as $rs)} <p>上一篇: <a href="{DIR}{$rs[url]}" title="{$rs[title] code='quote'}">{$rs[title]}</a></p> {#endforeach} {#else} <p>上一篇: 没有了</p> {#endif}
{@res.join table1='%s_content' table2='%s_content_categroy_bind' field1='title,url' on='id' where="t1.mid=1 and t1.status=1 and t1.id >{$info['id']}" number='1'} {#if(!empty($res))} {#foreach($res as $rs)} <p>下一篇: <a href="{DIR}{$rs[url]}" title="{$rs[title] code='quote'}">{$rs[title]}</a></p> {#endforeach} {#else} <p>下一篇: 没有了</p> {#endif}
转载请注明出处:唯众网络