Developer Blog

  • Blog
  • /
  • New Pagination Module Released
By Dracony on 19 August 2013

A new module for paginating your content has jst been released. You can extend it to paginate virtually anything, but it supports paginating ORM Models out of the box. It’s pretty straightforward to use too. here is a very basic example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Inside the controller
$current_page = $this->request->param('page');
$fairies = $this->pixie->orm->get('fairy');
$pager = $this->pixie->paginate->orm($fairies, $current_page, 5);
$pager->set_url_route('fairies');
$this->view->pager = $pager;
``````php?start_inline=1
// Rendering the pager inside a view
<ul>
    <?php for($i=1; $i<=$pager->num_pages; $i++): ?>
        <li>
            <a href="<?php echo $pager->url($i);?>"><?php echo $i;?></a>
        </li> 
    <?php endfor;?>
</ul>

Of course to get a more detailed explanation on how to use it check out the Pagination Module documentation.

comments powered by Disqus