KohanaPagination paging tutorial (Kohana3.3)

Source: Internet
Author: User
Tags kohana
There is almost no difference between the paging mode of Kohana3.3 and the previous version, but it seems that the Kohana framework does not bring the Paginationmodule by default. you can click here to download it. Step 1: enable the paging mode in bootstap. php.

There is almost no difference between the paging of Kohana 3.3 and the previous version, but it seems that the Kohana framework does not bring the Pagination module by default. you can click here to download it.
Step 1: enable the paging module in bootstap. php:

  Kohana::modules(array(  'pagination'  => MODPATH.'pagination',  ));

In the controller, you can write as follows:
/** By www.phpddt.com */public function action_view () {$ articles = ORM: factory ('article')-> join ('Category ')-> on ('article. cid ',' = ', 'Category. id '); $ pager = Pagination: factory (array ('total _ items' => $ articles-> count_all (), 'items _ per_page '=> 4, 'First _ page_in_url '=> TURE,); $ data ['articles'] = $ articles-> offset ($ pager-> offset) -> limit ($ pager-> items_per_page)-> find_all (); $ data ['pager'] = $ pager; $ this-> _ title ('Article list '); $ this-> _ render ('_ body', $ data, 'Test/list ');}

I have rewritten the Kohana view rendering and variable passing, so you can see the code above, as long as you pay attention to the use of paging:
        $pager = Pagination::factory(array(                'total_items'       => $articles->count_all(),'items_per_page'    => 4,                'first_page_in_url' => TURE,        ));

This paging class is super simple. for specific configuration parameters, see the source code, and then in the view:
    
     
 
  $ A):?> 
   
Serial Number Title Category Content
Aid?> Title?> Cid?> Content?>

:
Download Pagination module (by www.phpddt.com#.rar)

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.