![]() |
Pagintaion - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Pagintaion (/showthread.php?tid=12516) |
Pagintaion - El Forum - 10-22-2008 [eluser]Rubiz'[/eluser] Hello everyone! Well, I'm trying first time use the pagination helper, it seams to be usefull and easy, but I think I'm missing something... I dont know how it should be the model function, I dont know wich number variables I should use, well, I'm totaly lost in how select results in model, wich variables de controller should work, well, someone could help please? It would be fine if user guide had an complete example of it :-) Thanx! Pagintaion - El Forum - 10-22-2008 [eluser]OES[/eluser] Hi Rubiz. Here is a sample of my code which will hopeully shed some light. First the controller where I am going to paginate some results. Code: function index() And here is a basic model (Files_model) with the function search_files. Code: function search_files( $data='', $perpage, $offset='' ) This should hopefully get you on the right track. Bare in mind I am passing everything to the view including the pagnation create links. Good Luck Lee Pagintaion - El Forum - 10-22-2008 [eluser]Rubiz'[/eluser] Oh! ![]() Pagintaion - El Forum - 10-22-2008 [eluser]satterle[/eluser] OES: I followed your directions exactly. I'm getting the proper perpage posts on the first page, but the page to page navigation doesn't display. On my view page, I have: Code: <?php Any suggestions? Pagintaion - El Forum - 10-23-2008 [eluser]OES[/eluser] This normally means that your settings are incorrect for either the offset or the base url. So first offset. If you have for example: domain.com/news/10 10 is your offest. So like my example your offset will be. Code: $offset = $this->uri->segment(2); Then the base again make sure its pointing to the correcr area where pag will take place. ie. Code: $url = $this->config->site_url(); Regards Pagintaion - El Forum - 10-23-2008 [eluser]satterle[/eluser] Thanks, OES. Turns out I didn't *exactly* follow your directions... Instead of Code: $pagination_config['total_rows'] = count($this->Files_model->list_files()); I had Code: $pagination_config['total_rows'] = count($data['results']); Once I figured that one out, everything works fine. |