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.

Comments

wretched sinner - saved by grace’s picture

Version: 6.10 » 7.x-dev

This will need to go against HEAD, and then (possibly, but unlikely) to be back ported. Nice idea!

alexanderpas’s picture

empty string minus one equals ????

also, the documnetation must be extended, something like
// Translate human readable page numbers to PHP offset logic

and vice verca

Jean-Philippe Fleury’s picture

StatusFileSize
new1006 bytes

OK, new patch.

catch’s picture

Status: Needs review » Needs work

Both of the comments need a period on the end. Not sure the wording is quite right, but don't have suggestions.

Jean-Philippe Fleury’s picture

StatusFileSize
new1008 bytes

catch wrote:
> Both of the comments need a period on the end.

New patch.

agileware’s picture

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

alexanderpas’s picture

Status: Needs work » Needs review

I think the comments in #5 are great.

Status: Needs review » Needs work

The last submitted patch failed testing.

alexanderpas’s picture

Title: Make consistent the GET page variable with the real page number » Make the GET page variable consistent with the real page number

grammar...

mfer’s picture

Version: 7.x-dev » 8.x-dev

This is, sadly, too late for D7. We should do this at the start of D8.

steven jones’s picture

Version: 8.x-dev » 7.x-dev
Assigned: Unassigned » steven jones

subscribe.

dave reid’s picture

Version: 7.x-dev » 8.x-dev
Assigned: steven jones » Unassigned
steven jones’s picture

Version: 8.x-dev » 7.x-dev
Assigned: Unassigned » steven jones

Cross posts galore!

steven jones’s picture

Version: 7.x-dev » 8.x-dev

Argh!!!

steven jones’s picture

Version: 8.x-dev » 7.x-dev
Status: Needs work » Needs review
StatusFileSize
new919 bytes

Just want to see what the test bot will make of this patch, then will move to D8.

Status: Needs review » Needs work

The last submitted patch, pager_0.patch, failed testing.

steven jones’s picture

Version: 7.x-dev » 8.x-dev
steven jones’s picture

Status: Needs work » Needs review
StatusFileSize
new9.95 KB

One last go...

steven jones’s picture

Version: 8.x-dev » 7.x-dev

for D7.

steven jones’s picture

Version: 7.x-dev » 8.x-dev

Victory! Patch is good for D7, but this issue should change in D8.

steven jones’s picture

Assigned: steven jones » Unassigned
steven jones’s picture

#18: drupal-385270.patch queued for re-testing.

shp’s picture

Subscribe

steven jones’s picture

#18: drupal-385270.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, drupal-385270.patch, failed testing.

steven jones’s picture

Status: Needs work » Needs review
StatusFileSize
new9.04 KB

Well, that was a very old patch, so a quick, cosmetic re-roll.

Akaoni’s picture

Subscribing.

steven jones’s picture

Status: Needs review » Needs work

The last submitted patch, drupal-385270-pager-consistent-26.patch, failed testing.

steven jones’s picture

Status: Needs work » Needs review
StatusFileSize
new9.02 KB

Re-roll.

steven jones’s picture

Status: Needs review » Needs work

The last submitted patch, drupal-385270-pager-consistent-30.patch, failed testing.

steven jones’s picture

Status: Needs work » Needs review
StatusFileSize
new7.66 KB

Re-roll of patch from #30

Jiou’s picture

#5: pager.patch queued for re-testing.

Kirschbaum’s picture

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

yuriy.sychenko’s picture

patch #18 for D7, not working for me :(
I have the blocks views with a full navigation

yuriy.sychenko’s picture

work, 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

steven jones’s picture

Views pagers don't use core's paging code I think, so you might have to patch views too,

avpaderno’s picture

Views is now part of Drupal 8. The patch should fix what Views does too, if that is not already done with the current patch.

steven jones’s picture

Status: Needs review » Needs work
mittalpatel’s picture

For Comment # 37, in D7 you need to make change in views_plugin_pager_full.inc file .

in function set_current_page($number = NULL)
change

    for ($i = 0; $i <= $pager_id || $i < count($pager_page_array); $i++) {
      $pager_page_array[$i] = empty($page[$i]) ? 0 : $page[$i];
      $pager_page_array[$i]-- ; //add this line to decrease the page number in query
    }

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mondrake’s picture

Issue summary: View changes
Status: Needs work » Closed (duplicate)
Related issues: +#1818040: Pager should start counting from 1, not 0

This is now a duplicate of #1818040: Pager should start counting from 1, not 0 which has fresher comments.

azovsky’s picture

StatusFileSize
new2.04 KB

All changes for Drupal 7 in one file.

mondrake’s picture

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