分页类http://blog.csdn.net/buyingfei8888/article/details/40260127
在内部组件分页类 文件名和一致
组件是在什么地方被载入进来的?在主配置文件中面
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYnV5aW5nZmVpODg4OA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">
实现分页效果也是分为4步:
控制器:
function actionShow1(){ $good_model = Goods::model();
$good_info = $good_model ->findAll();
//设置总数目和每页显示数量
$cnt = $good_model -> count();
$per = 6;
//1 实例化对象
$page = new Pagination($cnt,$per);
//2 又一次组装sql语句
$sql = "select * from {{goods}} $page->limit";
$good_info = $good_model ->findAllBySql($sql);
//3 显示分页列表
$page_list = $page ->fpage(array(3,4,5,6,7));
// echo $page_list;
//4 将其分
配模板
$this ->renderPartial('show',array('goods_infos' => $good_info,'page_list' => $page_list));
}
将下句代码显示在模板中(须要显示分页的地方)
<?php echo $page_list;? >
就这是这么任意
效果:
假设想显示很多其它效果把上面控制器做改变
//3 显示分页列表
//$page_list = $page ->fpage(array(3,4,5,6,7));
$page_list = $page ->fpage();
效果如图:
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYnV5aW5nZmVpODg4OA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">
为毛要这样,请看分页类原代码:
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYnV5aW5nZmVpODg4OA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="">
版权声明:本文博主原创文章,转载请注明出处 http://blog.csdn.net/buyingfei8888