php
public function index($type=1)
{
$arr = model('Share')->where(['status'=>1,'group_id'=>$type])->with('group')->field('id,group_id,title,subtitle,image,price,createtime')->order('weigh desc')->paginate(1, false, [
'query' => Request::instance()->param(),//不丢失已存在的url参数
]);
$this->view->assign('arr', $arr);
$title = '暂无数据';
if(count($arr)>0){
$title = $arr[0]['group']['name'];
}
$page = $arr->render();
$this->view->assign('title', $title);
$this->assign('page', $page);
// 获取分页显示
return $this->view->fetch();
}
//模板使用方法{$page}
<section id="about" class="about_us section-padding" style="margin-top:70px;">
<div class="container">
<div class="row">
<div class="section-title text-center">
<h2>{$title}</h2>
<span></span>
</div>
{foreach $arr as $k=>$vo}
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="single_our_work">
<div class="sing_work_photo">
<figure>
<a href="detail.html?id={$vo.id}"><img src="{$vo.image}" alt="img"></a>
<h4><a href="detail.html?id={$vo.id}">{$vo.title}</a></h4>
</figure>
</div>
</div>
</div><!--- END COL -->
{/foreach}
</div><!-- END ROW -->
{$page}
</div><!-- END CONTAINER -->
</section>