Pagination does not display the correct number of pages internally, but visibly shows the correct number of pages, causing it to default to page 1 after x
Permalink
Hello, I am having a very odd problem with my block. I am using pagination. When you click on a high number page, for example 16, or click the end page (like 10, 32, etc, the one that appears after the '...') it shows the correct page number in the URL, but wrong page objects in the page (defaults to page 1).
This is all i'm using to generate my Pagination with a basic file list:
Prev/next works fine, it's just when you start to click higher page numbers, or when you click the last page number.
This is all i'm using to generate my Pagination with a basic file list:
Loader::model('file_list'); $fl = new FileList(); $fl->filterBySet($fs); $pagination = $fl->getPagination(); $pagination->setMaxPerPage(5); $fileListPages = $pagination->getCurrentPageResults();
Prev/next works fine, it's just when you start to click higher page numbers, or when you click the last page number.
Figured it out, and very strange.
I noticed that no matter what i set "$pagination->setMaxPerPage()" to, it seemed to default the "available pages" as if i had set max per page to 10. Meaning if i had 100 items, it would always show 10 pages internally (to the class), but if i had 5 setMaxPerPage(5), it would show that there was 20 pages available, and it would show 5 items per 5, but anything after page 10 wouldnt "exist" to the pagination.
Here's my solution:
I noticed that no matter what i set "$pagination->setMaxPerPage()" to, it seemed to default the "available pages" as if i had set max per page to 10. Meaning if i had 100 items, it would always show 10 pages internally (to the class), but if i had 5 setMaxPerPage(5), it would show that there was 20 pages available, and it would show 5 items per 5, but anything after page 10 wouldnt "exist" to the pagination.
Here's my solution:
$fl->setItemsPerPage(5); $pagination = $fl->getPagination(); $fileListPages = $pagination->getCurrentPageResults();
The class:
If I dump these things ($pagination is from the code provided in first post)
I get:
Well no wonder why it's not paging right, it's missing half the pages! It should have 26 pages. 126/5 = 25.2.
Why would this be so wrong? For clarification, my fileset does have 126 images in it.