Combine the PHP paging class with the YII framework and change the style as needed

Source: Internet
Author: User

Pagination Class http://blog.csdn.net/buyingfei8888/article/details/40260127

The paging class is placed in the component and the file name is consistent


Where is the component loaded in? In the main configuration file


It is also divided into 4 steps to achieve paging effect:

Controller:

 function                    ActionShow1 () {$good _model = Goods::model ();                    $good _info = $good _model->findall ();                    Sets the total number and the number of displays per page $cnt = $good _model, count ();                     $per = 6;                    1 Instantiating Object $page = new Pagination ($cnt, $per);                    2 reassemble 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 (3,4,5,6,7));                   echo $page _list; 4 Divide it into 
With template                    $this->renderpartial (' Show ', Array (' goods_infos ' = ' + ' $good _info, ' page_list ' = = $page _list));                }
Display the following code in the template (where paging is required)

  <?php echo $page _list;? >

It's so casual.

Effect:


If you want to show more effects, change the above controller.

3 Display page List//$page _list = $page->fpage (Array (3,4,5,6,7)), $page _list = $page->fpage ();

Effect


For Mao to do this, look at the pagination class original code:



Combine the PHP paging class with the YII framework and change the style as needed

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.