Pagination with PageList model
Permalink 4 users found helpful
Working on pagination my PageList model. Currently its pagination the items however I'm having a tough time figuring out the rest of the methods for Prev, Next, Current. All the functions that PaginationHelper does.
On my single_page:
In my PageList Model:
Do I need to use the PaginationHelper? How would I implement it in my current code?
Thanks!
On my single_page:
<?php Loader::model('transactions_list'); $tl = new TransactionsPageList; if($tl->getSummary()->pages > 1) { $tl->getPaginiation(); } ?> <div class="paging"> <ul> <li><a href="#" class="prev">prev</a></li> <li><a href="#"><?php echo $tl->getCurrentPage(); ?></a></li> <li>of</li> <li>4</li> <li><a href="#" class="next">next</a></li> </ul>
Viewing 15 lines of 17 lines. View entire code block.
In my PageList Model:
<?php defined('C5_EXECUTE') or die("Access Denied."); Loader::model('page_list'); class TransactionsPageList extends PageList { public function __construct(){ $this->filterByParentID(183); $this->sortByDisplayOrder(); $this->setItemsPerPage(2); } public function filterBy($filter=null){ if($filter == null || $filter == 'ALL') { return; } else { $this->filterByAttribute('sectors', '%'.$filter.'%', 'like'); }
Viewing 15 lines of 18 lines. View entire code block.
Do I need to use the PaginationHelper? How would I implement it in my current code?
Thanks!
Still struggling. Any help would be awesome!
I'm having a little trouble understanding a specific question, but maybe this helps. People typically do paging by passing the page list to the view with
Then in your view you throw this in
If you are trying to roll your own a bit
//in controller $page_list = new PageList(); $page_list->filterByAllKindsOfStuff('blah'); $pages = $page_list->getPage(); $this->set('page_list', $page_list); $this->set('pages', $pages);
Then in your view you throw this in
//in view $page_list->displayPaging();
If you are trying to roll your own a bit
//in controller $page_list = new PageList(); $page_list->filterByAllKindsOfStuff('blah'); $pages = $page_list->getPage(); // This returns a pagination helper object $pagination = $page_list->getPagination(); $this->set('page_list', $page_list); $this->set('pages', $pages); $this->set('pagination', $page_list);
Ah I was so close! You are the man! Thanks as always mkly!