Combine the php paging class with the YII Framework and change the style as needed

Source: Internet
Author: User
Combine the php paging class with the YII Framework and change the style pagination class http://blog.csdn.net/buyingfei8888/article/details/40260127 as needed

The file name of the paging class in the component must be consistent with that of the component.


Where is the component loaded? In the main configuration file


The implementation of paging effect is also divided into four steps:

Controller:

Function actionShow1 () {$ good_model = Goods: model (); $ good_info = $ good_model-> findAll (); // set the total number and displayed quantity per page $ cnt = $ good_model-> count (); $ per = 6; // 1 instantiate object $ page = new Pagination ($ cnt, $ per); // 2 re-assemble the SQL statement $ SQL = "select * from {goods} $ page-> limit "; $ good_info = $ good_model-> findAllBySql ($ SQL); // 3 display the paging list $ page_list = $ page-> fpage (array (, 7 )); // echo $ page_list; // 4 divide it
Configuration template $ this-> renderPartial ('show', array ('goods _ infos '=> $ good_info, 'page _ list' => $ page_list ));}
Display the following code in the template (where pagination is required)

  
 

This is so casual.

Effect:


If you want to display more results, change the controller above.

// 3 display the page List // $ page_list = $ page-> fpage (array (3, 4, 5, 6, 7); $ page_list = $ page-> fpage ();

Effect


For Mao, see the original code of the paging class:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.