[SOLVED] Paging Numbers

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.

Pagination class takes care of it for you.

So, are you saying not to configure num_links?

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.


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...

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?

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

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.