新闻详情页文章上下翻页:
~~~
public function detail(){
$id = input('id'); //接收ID
$InfoDetail = Db::table('wz_news_article')->where('id',$id)->find(); //查询数据
$befor = Db::table('news')->where('id>'.$id)->order('id desc')->limit('1')->find(); //下一页
$after = Db::table('news')->where('id<'.$id)->order('id desc')->limit('1')->find(); //上一页
$this->assign(['data'=>$InfoDetail,'before'=>$before,'after'=>$after ]);
return $this->fetch();
}
~~~
前端页面上下翻页按钮展示:
~~~
<a href="{$after['id']}" class="kai prev">
<i></i>
<span></span>
<p>{if condition="$after['id'] neq ''"}{$after['title']}{/if}NULL</p>
</a>
<a href="{$befor['id']}" class="kai next">
<p>{if condition="$befor['id'] neq ''"}{$befor['title']}{/if}NULL</p>
<span></span>
<i></i>
</a>
~~~