Home > Backend Development > PHP Tutorial > 将php分页类与YII框架结合并根据需要改变样式

将php分页类与YII框架结合并根据需要改变样式

WBOY
Release: 2016-06-23 13:47:20
Original
909 people have browsed it

分页类http://blog.csdn.net/buyingfei8888/article/details/40260127

分页类放在组件里面 文件名称与保持一致


组件是在什么地方被加载进来的?在主配置文件里面 


实现分页效果也是分为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 将其分
Copy after login
配模板                    $this ->renderPartial('show',array('goods_infos' => $good_info,'page_list' => $page_list));                }
Copy after login
将下句代码显示在模板中(需要显示分页的地方)

  <?php echo $page_list;?>
Copy after login

就这是这么随意

效果:


如果想显示更多效果把上面控制器做改变

//3 显示分页列表 //$page_list = $page ->fpage(array(3,4,5,6,7));$page_list = $page ->fpage();
Copy after login

效果如图:


为毛要这样,请看分页类原代码:



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template