Drupal's pagination is a bit geeky: it starts from 0 instead of 1. If we are on the first page and we click on the number 2 (or on the "next" link) in the navigation bar, we're displaying the second page, but the $_GET['page'] variable on the url is ?page=1.
$_GET['page'] variable is one lower than the real page number marked in the navigation bar. For most people, I think that it's a bit disconcerting and not ergonomics.
I attach a patch that makes pagination start to 1 instead of 0. See http://drupal.org/node/73207#comment-961385 Thanks to LanceLight.
| Comment | File | Size | Author |
|---|---|---|---|
| #45 | d7-pager-fix-385270-45.patch | 2.04 KB | azovsky |
| #33 | drupal-385270-pager-consistent-33.patch | 7.66 KB | steven jones |
| #30 | drupal-385270-pager-consistent-30.patch | 9.02 KB | steven jones |
| #26 | drupal-385270-pager-consistent-26.patch | 9.04 KB | steven jones |
| #18 | drupal-385270.patch | 9.95 KB | steven jones |
Comments
Comment #1
wretched sinner - saved by grace commentedThis will need to go against HEAD, and then (possibly, but unlikely) to be back ported. Nice idea!
Comment #2
alexanderpas commentedempty string minus one equals ????
also, the documnetation must be extended, something like
// Translate human readable page numbers to PHP offset logic
and vice verca
Comment #3
Jean-Philippe Fleury commentedOK, new patch.
Comment #4
catchBoth of the comments need a period on the end. Not sure the wording is quite right, but don't have suggestions.
Comment #5
Jean-Philippe Fleury commentedcatch wrote:
> Both of the comments need a period on the end.
New patch.
Comment #6
agileware commentedThis is an excellent idea.
A couple of suggestions for the comments if you don't want these ones:
// Translate human readable page numbers to PHP offset logic.
could be:
// Translate one based page numbers to be zero based for php usage.
// Translate PHP offset logic to human readable page numbers.
could be:
// Translate zero based page numbers to be one based for better human readability.
Comment #7
alexanderpas commentedI think the comments in #5 are great.
Comment #9
alexanderpas commentedgrammar...
Comment #10
mfer commentedThis is, sadly, too late for D7. We should do this at the start of D8.
Comment #11
steven jones commentedsubscribe.
Comment #12
dave reidComment #13
steven jones commentedCross posts galore!
Comment #14
steven jones commentedArgh!!!
Comment #15
steven jones commentedJust want to see what the test bot will make of this patch, then will move to D8.
Comment #17
steven jones commentedComment #18
steven jones commentedOne last go...
Comment #19
steven jones commentedfor D7.
Comment #20
steven jones commentedVictory! Patch is good for D7, but this issue should change in D8.
Comment #21
steven jones commentedComment #22
steven jones commented#18: drupal-385270.patch queued for re-testing.
Comment #23
shp commentedSubscribe
Comment #24
steven jones commented#18: drupal-385270.patch queued for re-testing.
Comment #26
steven jones commentedWell, that was a very old patch, so a quick, cosmetic re-roll.
Comment #27
Akaoni commentedSubscribing.
Comment #28
steven jones commented#26: drupal-385270-pager-consistent-26.patch queued for re-testing.
Comment #30
steven jones commentedRe-roll.
Comment #31
steven jones commented#30: drupal-385270-pager-consistent-30.patch queued for re-testing.
Comment #33
steven jones commentedRe-roll of patch from #30
Comment #34
Jiou commented#5: pager.patch queued for re-testing.
Comment #35
Kirschbaum commentedJust tried #33 patch on latest stable release of D7. Everything was applied successfully except for this...Oops. That was not the D7 patch. Patch in #18 was applied successfully to D7. However, when used in conjunction with a paged View, using the pagination controls now jumps the page from nothing (0) to 2 to 4. Hmm...
Comment #36
yuriy.sychenko commentedpatch #18 for D7, not working for me :(
I have the blocks views with a full navigation
Comment #37
yuriy.sychenko commentedwork, there was a problem in the on side of the module, but the block views when you go to the link say "?page=4" becomes active link 5 in the pager
Comment #38
steven jones commentedViews pagers don't use core's paging code I think, so you might have to patch views too,
Comment #39
avpadernoViews is now part of Drupal 8. The patch should fix what Views does too, if that is not already done with the current patch.
Comment #40
steven jones commentedComment #41
mittalpatel commentedFor Comment # 37, in D7 you need to make change in views_plugin_pager_full.inc file .
in function set_current_page($number = NULL)
change
Comment #44
mondrakeThis is now a duplicate of #1818040: Pager should start counting from 1, not 0 which has fresher comments.
Comment #45
azovsky commentedAll changes for Drupal 7 in one file.
Comment #46
mondrakeI am trying to implement this in the contrib Pagerer module, see #3091945: Allow Pagerer to override the pager querystring part in URLs and count pages from 1, not 0. Reviews, tests, suggestions would be appreciated there.