Problem/Motivation

The pager starts counting from 0, which for a human is very confusing as no page 0 exists. This also causes the page numbers displayed in the pager and in the URL to be different from each other.

Now when Views is looking to get into D8, then #1024226: Option to start Pager count at 1 instead of 0 is related to this as well. Unless they will merge into one pager.

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Prioritized changes The main goal of this issue is usability.
Disruption This change should not disrupt the internal behaviors of the paging system if the internal counter is unaltered, but will change hardcoded links to specific pages of content, which might require updates to some existing sites.

Proposed resolution

Do not alter the internal page number, but only show a pager starting at 1 in the URL.

Remaining tasks

Contributor tasks needed
Task Novice task? Contributor instructions Complete?
Create a patch Instructions
Update the issue summary Instructions Done in #9
Update the issue summary noting if allowed during the beta Instructions Done in #9
Add automated tests Instructions
Draft a change record for the API changes Instructions

User interface changes

None

API changes

None

Comments

c-logemann’s picture

I think we have two problems here.

1. One Problem is the logic of starting a count at 0 or at 1. This a kind of philosophical question and similar to counting floors which is handled different in different countries: http://en.wikipedia.org/wiki/Storey
When I started with drupal I was also confused by this. But this is something to learn. Maybe this could be optional but because of existing projects and a kind of upgrade path for content and content lists from drupal 7 to drupal 8 (in logic of bookmarks) I don't like a hard change in the URL logic of paging lists.

2. The other problem is a difference of what the URL and the pager is showing. This is really confusing. But because of problem 1 I think it's not the best way to solve this with changing the counting logic. I think it would be better to add the "page 0" logic to the pager.

aspilicious’s picture

We get regular client "bug" reports about this. I would love to have an option to just bump the number by one. Page 0 logic doesn't makes sense in my opinion. But I guess not everyone is the same ;)

AFTER reading the linked issues I don't think it's a good idea after all because there will be mismatch between core and views pagers.

tsvenson’s picture

@C_Logemann:

While I do understand your points, this really is about how this is confusing for site visitors. They don't really care much about what a site is built on, they are there for the content.

We need to stop mixing what we as Drupal developers/users know about how Drupal does things and what site users/consumers need when visiting sites built with it. Those two are completely different worlds.

@aspilicious:

Since the Views devs refer to this as a core issue (already when I first filed the issue), I interpret that as Views is actually using the core pager. Thus, if this is fixed in core, then Views will automatically benefit from that too.

c-logemann’s picture

@aspilicious: As I understand merlinofchaos and dawehner is views following the logic of the core. And since views is part of the core there would be no difference because any change of this (if we want to) has to be also a change of views.

Anonymous’s picture

I'll put my two pennies in. The internal data can remain as 0 but the displayed data must be represented as starting at 1. I have been known to create my own pager code based on core to do the representation as starting at 1. Most sites do paging with the pager starting at 1 which confuses the users who visit a drupalized site. It would be really nice to not have to create my own code because I see starting with 0 as wrong for my users.

penyaskito’s picture

Issue summary: View changes
Issue tags: +Usability
dawehner’s picture

Well, you could for sure use url outbounding and inbounding to change the URL if you like.

The question really is whether we should change that logic given that we still show node IDs for example.

quotesbro’s picture

Absolutely agree with @earnie's #5.

duaelfr’s picture

Issue summary: View changes
xjm’s picture

Issue summary: View changes

In terms of the disruption this would introduce, I added a note about changes to links to specific pages in the pager.

duaelfr’s picture

Assigned: Unassigned » duaelfr

Starting to work on this.

lanny heidbreder’s picture

lanny heidbreder’s picture

lanny heidbreder’s picture

Issue summary: View changes
duaelfr’s picture

Assigned: duaelfr » Unassigned
Status: Active » Needs review
StatusFileSize
new6.63 KB

I'm not sure that this patch completely fixes the issue but that's a start.
I'll spend more time on this later. Please do not wait to start reviewing.

I've found that the common pager was used in the following places:
- all views pagers (easy to test on the defaut home page)
- user admin interface
- url aliases admin interface

I've found no automated tests and that include files does not seem to be tested anywhere so I'll probably need to ask out on #drupal-contribute if there is a way to automate tests on these functions or not.

Status: Needs review » Needs work

The last submitted patch, 15: drupal-8.0.x-better_page_number-1818040-15.patch, failed testing.

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 15: drupal-8.0.x-better_page_number-1818040-15.patch, failed testing.

Status: Needs work » Needs review
wim leers’s picture

Wow, this issue makes so much sense. Yes please, let's be nice to humans, not robots!

duaelfr’s picture

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

My patch was not working 7 months ago.
I think it's going to need a deep reroll before anything can be done.

There is no way that this could land in 8.0.x so I just changed the target version.
I'm not even sure it could be done in 8.x as it's probably going to break BC of some contrib modules.

wim leers’s picture

I'm afraid this is even 9.x, unless we have a setting to make sure existing sites don't get this. Otherwise URLs would break…

mondrake’s picture

If we could do at least #2044435: Convert pager.inc to a service in a 8.x minor, then contrib may override the pager service and do whatever. But yes, entire sites could break :) - it's not a setting that could be changed lightheartedly.

joelpittet’s picture

Version: 8.1.x-dev » 9.x-dev
Status: Needs review » Postponed

Triagging this for 9.x as mentioned in #22 and #23

lanny heidbreder’s picture

I'm not surprised, but that is freaking infuriating. The issue by itself exemplifies how seriously Drupal people DON'T take usability, and the fact that this has been tagged d8ux for months and no one even checked it until it was too late shows it even more.

I blame myself for not agitating more about this, but it's really discouraging that such a horrible blemish is going to remain for three or four more years.

wim leers’s picture

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

unless we have a setting to make sure existing sites don't get this. Otherwise URLs would break…

Back to 8.x.1.x-dev because of that.

#25: this is the kind of thing that is not noticed that often. And it's easy to get used to. If this would have gotten on my radar in 2013 or 2014, I totally would've pushed for this. We do care about usability. But the usability impact of this is far lower than that of other things. Software is never finished. We always need to prioritize things, and that means not doing certain things, unfortunately! :(

joelpittet’s picture

@75th Trombone you can totally help this type of thing get in to core. This needed to be completed, tested and set to RTBC. Even if you can't contribute with code you can bring it up in the #drupal-contribute or #drupal-usability channels and get attention to people that can help push this forward. Or look in core/MAINTAINERS.txt to see who to discuss this part of core with.

I 100% agree with what @Wim Leers said and thanks @Wim Leers for giving some hope for 8.1.x inclusion.

We do care but this is the first I've noticed this issue too and would have also tried to help get this in if I knew about it. I don't actively triage the "base system" component or usability tag because I've had my hands full with Twig. I just happened upon this while looking for WSCCI stuff.

lanny heidbreder’s picture

Thanks for the encouragement, guys, and sorry I got upset for a minute — the prospect of waiting for a change for years made my stomach turn a bit. :)

I'll follow your advice as best I can, and thanks, @joelpittet, for pointing me to #drupal-usability, which I was unaware of!

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

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now 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.

Nathan Goulding’s picture

Isn't this addressed here? https://www.drupal.org/node/385270

mondrake’s picture

#30: yes that seems a duplicate of this one. Latest comments here are definitely fresher, though. Will add a reference to #385270: Make the GET page variable consistent with the real page number in the plan issue #2547833: Pager.inc -- add tests, clean it up, convert to a service, use it!, for completeness.

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

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now 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.

joelpittet’s picture

Status: Postponed » Active

Whoops this shouldn't be postponed.

joelpittet’s picture

Issue tags: +Needs tests

This could probably use Browser tests or Functional tests to ensure this isn't changed by accident.

zeip’s picture

Issue tags: +Dublin2016
dawehner’s picture

I am not sure why having some URL is really adding usability. Who is seriously navigating using query parameters.

Note: For REST API you would certainly get confused by pagers starting with 1.

lanny heidbreder’s picture

I am not sure why having some URL is really adding usability. Who is seriously navigating using query parameters.

I ranted a bit about the page number problem on the related issue

Note: For REST API you would certainly get confused by pagers starting with 1.

Agreed. The internal number should still be 0 for developers, but all user-facing displays (and the URL is a user-facing display) should start with 1.

joelpittet’s picture

@dawehner it's usability because it's visible to the end user in typically a prominent position (location bar) and indicates the page they are on, and is associated by the pager links for correlation and assurance. Also one reason why we have URL aliases in the same sense, it's user friendly.

dawehner’s picture

Well, we cannot change the behaviour by default now. URLs point to those sites already, so changing those might break existing links out there in the wild.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

vorapoap’s picture

Are there any update on this issue on Drupal8.x ?
Is the patch file from DuaelFr working with Drupal8 ?

shabana.navas’s picture

Patch does not apply cleanly. But from the above comments, it seems this change might break some existing links.

cilefen’s picture

I do not want to discourage people on this issue. If you can work out a way to not break URLs on existing sites, and is not burdensome to maintain, try it. See #2751325: All serialized values are strings, should be integers/booleans when appropriate for a similar compatibility situation.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

pwaterz’s picture

Why not just add a setting to views to allow setting the starting index? The seems like a safer approach then trying to make a non breaking change.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

darvanen’s picture

This could be solved if we could turn the pager into a service as per #2547833: Pager.inc -- add tests, clean it up, convert to a service, use it!.

neibo’s picture

DuaelFr can you update your patch for Views please?

duaelfr’s picture

@neibo Sadly, no. My patch never worked and is really outdated so it would need a huge investment to make it work. Plus, as told in #47, there is some work in progress to convert pagers to services so they are going to be more manageables.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

adrianavaz’s picture

Any update on this?

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.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.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

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.

mondrake’s picture

Pagerer 8.x-2.0-beta1 now allows to change the index base from zero to one, still keeping compatibility with the standard format.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

weekbeforenext’s picture

I'm taking a look at this feature from the perspective of 8.9.x because it's the version I'm currently working in.

I wanted to share my thoughts regarding the plan to see if anyone has feedback before I dig too far into this.

Does this make sense or is there a better place to put a Pager configuration setting since it doesn't only affect views?

  • A checkbox in the Views > Settings > Advanced form with the label "Start pager index at 0".
  • A new boolean configuration setting for views: pager_index_base_zero
  • An update function in the views module that sets this config value to true, to protect existing sites.

The harder part is finding the right place to implement. If the setting is stored within the views module, I'm looking for a way to pass the configuration setting to the Pager service logic so that it will work as expected for views and using the Pager outside of views will also allow an optional base index setting.

I think this is a cool problem to solve, so I want to make sure I'm heading down the right path to increase the chances the patch will be merged.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

azovsky’s picture

Any update on this?

johnv’s picture

Title: Make pager start counting from 1, not 0 » Pager should start counting from 1, not 0
Component: base system » views.module
Status: Active » Closed (outdated)

Thisis fixed ITMT.

The pager starts with 1, whereas the URL starts with 0.

penyaskito’s picture

Component: views.module » base system
Status: Closed (outdated) » Active

This is still an issue as of the URL argument. Also involves every paging, not only views. Reopening.

johnv’s picture

Component: base system » views.module
Category: Task » Bug report

I am triaging all pager issues. But need ot organize the first.
Since not all agree on the necessity, let's move this to Bug report, not Task,
And move to Views module, even though is is change din Database lib.

nicxvan’s picture

Component: views.module » base system

Not all pagers are in views, are you sure this issue is about the views pager?

There is mention for both core prayer and views it probably belongs in base.

Do you have an issue to discuss what your plan is for pagers?

At the moment it just seems like you are bulk renaming issues that have not been touched in years and have no patches or work.

If there is a planning issue it would be nice if you could link to it.

If not please create one and link to it, so we can discuss process.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.