CodeIgniter Forums
[SOLVED] Paging Numbers - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: [SOLVED] Paging Numbers (/thread-23744.html)



[SOLVED] Paging Numbers - El Forum - 10-20-2009

[eluser]stuffradio[/eluser]
What math do you use for getting the number of pages in your pagination? Should I take the total rows and divide by 2 or something? Or I guess maybe I should take the total rows and divide by the rows per page... the only thing wrong with that is sometimes it would display more pages than needed.


[SOLVED] Paging Numbers - El Forum - 10-21-2009

[eluser]n0xie[/eluser]
Pagination class takes care of it for you.


[SOLVED] Paging Numbers - El Forum - 10-21-2009

[eluser]stuffradio[/eluser]
So, are you saying not to configure num_links?


[SOLVED] Paging Numbers - El Forum - 10-21-2009

[eluser]SneakyDave[/eluser]
You don't need to configure num_links unless you want to, it's optional, and only shows how many page links BESIDE the current page to display. It seems I ALWAYS have to configure the uri_segment, as CI doesn't set it for me, like it should.

http://ellislab.com/codeigniter/user-guide/libraries/pagination.html

I fought for a while with the pagination class thinking the links it generated were wrong, but realized that the links it generates are for the number of results to skip per page, not the page number, so your links for pages 1,2,3,4 would look like this if you have assigned 20 results per page...
http://yoursite.com/page/
http://yoursite.com/page/40
http://yoursite.com/page/60
http://yoursite.com/page/80

And the pagination class would only generate the necessary number of page links based on the total_rows.

One thing I haven't been able to figure out is how to use the pagination in a config file named pagination.php.

I can create the /config/pagination.php file with the $config array setting the options I want, but how do I set the total_rows from the result? I can't do it in the pagination.php file because I don't know the number of rows at that point in time. So can I set some of the pagination options in the config file, and the total_rows in my controller?


[SOLVED] Paging Numbers - El Forum - 10-21-2009

[eluser]stuffradio[/eluser]
Yeah it's working properly now... I think it had to do with something else but this solution of removing num_links worked fine as well Wink