![]() |
Pagination produces the wrong page number - 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: Pagination produces the wrong page number (/showthread.php?tid=21371) |
Pagination produces the wrong page number - El Forum - 08-07-2009 [eluser]gevans[/eluser] I've been trying to sort out this issue I'm having with the pagination class, but it's the first time I've used it and I'm stumped. Code: $this->load->library('pagination'); The html outputted is Code: <strong>1</strong> <a href="http://localhost/site/search/agents/france/alsace/3">2</a> <a href="http://localhost/site/search/agents/france/alsace/3">></a> As you can see, though the text in the anchor tag is the number two, the actual href uses a 3. Any ideas? Cheers, Gareth Pagination produces the wrong page number - El Forum - 08-07-2009 [eluser]gevans[/eluser] Ignore me, I've always passed page numbers in my URI not the offset. I was under the impression that this pagination script was using page numbers not the offset amount (as it wasn't documented otherwise). All sorted now. Pagination produces the wrong page number - El Forum - 08-07-2009 [eluser]Colin Williams[/eluser] The parameter for pagination (segment 5) is actually the offset, not the page number. So, page two would have an offset of 3, page 3 would have an offset of 6, etc. EDIT: Sorry, didn't see your clarification before I posted. Pagination produces the wrong page number - El Forum - 08-07-2009 [eluser]gevans[/eluser] Cheers for that. I think I could've solved it a lot faster if it wasn't for the fact that I only had 2 pages with an offset or 3. To little things that made it very confusing to have page 2 showing as 3 (so I thought) ![]() Thanks again. Pagination produces the wrong page number - El Forum - 08-07-2009 [eluser]David Johansson[/eluser] I don't like the pagination class, so I rewrote all of it in my own adaptation. One of the changes I made was to let the URI pass the page number instead of the offset. I also created a function that would receive the current page (instead of getting it from the URI) so it would go throught the same validation process. Also I made it possible to add inactive prev/next-buttons with custom text if you for instance want to have a grayed out image showing when you can't go to next/prev page (same with first/last)- Finally I also accept 0 as num_link that would show all pages as links. If someone's interested in the code PM me ![]() |