Problem/Motivation

While creating a view, user requested to see all records on 1 page. The previous pager setting was 'Display a specified number of items" and a value of 10.

I left the pager type as it was and set the pager value to '0' (which Views field Items Per Page 'help' text suggests). The result on the views screen says "Display a specific number of items | 0 items". I completely understand why and how but for human readability it is nonsensical. When the value is '0' this should exception to 'All' items.

Steps to reproduce

Create a view.
Set Pager to : Use Pager: Display a specified number of items. Accept the defaults (10 items with skip of 0).
From view click on the pager '10 items' hyperlink and set the value to 0.

Proposed resolution

If the user sets the pager type to "Display number of items" and

  1. offset is set to 0, the number items is set to 0, display text string 'All' instead of numeric 0.
  2. offset is set to 0, the number items is set is not 0, display text string 'All items except first @offset'.

For all the other combinations, the display text on the pager option link remains unchanged.
This does not change the existing logic and behaviour of the pagination which and also clears the confusion about the behaviour.

Remaining tasks

See the tags and the MR
Followup for #24

User interface changes

Before

After

API changes

Data model changes

Release notes snippet

Issue fork drupal-3183766

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jshimota01 created an issue. See original summary.

larowlan’s picture

Issue tags: +Novice, +Bug Smash Initiative

Thank you for a detailed bug-report

pameeela’s picture

Not exactly a duplicate, but #2791455: Pager option 'Items per page' with exposed value 0 should by default show 'All items' on view shows a use case for setting it to 0. I don't think we can change the behaviour to default to something else as it would break existing sites relying on this.

lendude’s picture

I agree with #3, it would be hard to change this behaviour and not break things. So yeah the option to display 'All' and not 0 sounds pretty good

alecsmrekar’s picture

Status: Active » Needs review
StatusFileSize
new1.25 KB

Attaching patch.

alecsmrekar’s picture

StatusFileSize
new1.2 KB
alecsmrekar’s picture

StatusFileSize
new1.21 KB
guilhermevp’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new80.29 KB

Patch works as intended. Screenshot attached.

djsagar’s picture

StatusFileSize
new118.66 KB
new142.26 KB
new118.66 KB
new142.26 KB

Patch is working fine and this issue resolved.

Thank you @alecsmrekar.

RTBC +1

djsagar’s picture

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/views/src/Plugin/views/pager/Some.php
@@ -19,10 +19,17 @@
-      return $this->formatPlural($this->options['items_per_page'], '@count item, skip @skip', '@count items, skip @skip', ['@count' => $this->options['items_per_page'], '@skip' => $this->options['offset']]);
+      $summary_text .= ', ' . $this->t('skip @skip', ['@skip' => $this->options['offset']]);

Concatenating translated string like this it not supported. It loses "safeness" and so any html in the translation will be lost and it doesn't give the translator the full context. All the the text this can result in...

"All items, skip 20"

... is pretty confusing too.

paulocs’s picture

Assigned: Unassigned » paulocs
paulocs’s picture

Assigned: paulocs » Unassigned
Status: Needs work » Needs review
StatusFileSize
new1.42 KB
new1.58 KB
paulocs’s picture

The patch #13 addresses comment #11.

guilhermevp’s picture

Status: Needs review » Needs work
StatusFileSize
new57.53 KB

The patch works perfectly, but this functionality should be added to full and mini view modes.

guilhermevp’s picture

Status: Needs work » Needs review
StatusFileSize
new3.3 KB
new4.88 KB

Just applied the solution from patch#13 to full and mini options, in order to standardizing the "All Items" view.

guilhermevp’s picture

StatusFileSize
new4.81 KB
new3.22 KB
guilhermevp’s picture

StatusFileSize
new4.09 KB
new5.67 KB
abhijith s’s picture

Applied patch #18 on 8.9.x and it works fine. Resolution "b" is available with display a specified no. of items. mini pager and full pager after this patch.Adding screenshots below.

After patch:

Display a specified no. of items mode
after

Full pager
after2

Mini pager
after3

RTBC +1

alexpott’s picture

Status: Needs review » Needs work
+++ b/core/modules/views/src/Plugin/views/pager/Full.php
@@ -68,10 +68,24 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
+        $summary_text = $this->t('All items, skip @skip', ['@skip' => $this->options['offset']]);

This is pretty confusing "All items, skip 10" is odd because it's not all items.

One thing we could ask is what is the point of a pager where the number of items per page is 0? I'm not sure that all items is the correct term here. When the UI has the test Use Pager: Full | 5 items it's pretty clear that 5 items are going to be displayed per page but Use Pager: Full | All items is not clear at all.

guilhermevp’s picture

I really could use some suggestions of a better phrasing for this solution.

What about:

$summary_text = $this->t('All items, except first @skip', ['@skip' => $this->options['offset']]); 
guilhermevp’s picture

StatusFileSize
new6.34 KB
new2.05 KB

Sending patch with phrasing changes addressing comment#20.

guilhermevp’s picture

Status: Needs work » Needs review
alexpott’s picture

@guilhermevp I think the problem here is that \Drupal\views\Plugin\views\pager\Mini and \Drupal\views\Plugin\views\pager\Full should adjust items_per_page to have a minimum value of 1. A value of 0 makes no sense - that's what the \Drupal\views\Plugin\views\pager\None is for. Also \Drupal\views\Plugin\views\pager\Some should have a should adjust items_per_page to have a minimum value of 1.

Making that change is complex because we'd need to update existing views that have 0 for items per page and are not using the None pager.

ilgnerfagundes’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new7.3 KB

The patch applies correctly and does what it should, if not making a mass change, it can be accepted

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

@ilgnerfagundes I think we should consider doing the better change here.

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

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

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

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

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should 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.

Manibharathi E R’s picture

StatusFileSize
new209.63 KB

Applied patch #23 on 9.4.x and it works fine.
After_patch

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

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should 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.

djsagar’s picture

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

Binoli Lalani made their first commit to this issue’s fork.

binoli lalani’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Seems like a change that needs test coverage.

sushyl’s picture

Issue tags: +Portland2024

Keeping the novice tag on this one after reviewing the issue.
This needs a simple assertion which can be added in the existing test SorePagerSettings to assert that when
- the number of items in the pager is set to `0`
- and the pager type is set to "Display a specified number of items"
the text on the pager option link is "All items" and not "0 items"

Novice issue reserved for the Mentored Contribution during the Contribution Day at DrupalCon Portland 2024. After the 8th of May 2024, this issue returns to being open to all. Thanks
ian.ssu’s picture

My name is Ian and I'm working today on this issue at DrupalCon 2024

ian.ssu’s picture

Status: Needs work » Needs review

I think I added the suggested test. Forgive the extra commits I was unable to get failing tests with DrupalPod.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs tests

No need to apologize. Tests were exactly what I was thinking

Ran test-only feature of gitlab https://git.drupalcode.org/issue/drupal-3183766/-/jobs/1550667

1) Drupal\Tests\views\Functional\Plugin\PagerTest::testStorePagerSettings
Behat\Mink\Exception\ResponseTextException: The text "All items" was not found anywhere in the text of the current page.
/builds/issue/drupal-3183766/vendor/behat/mink/src/WebAssert.php:907
/builds/issue/drupal-3183766/vendor/behat/mink/src/WebAssert.php:293
/builds/issue/drupal-3183766/core/tests/Drupal/Tests/WebAssert.php:975
/builds/issue/drupal-3183766/core/modules/views/tests/src/Functional/Plugin/PagerTest.php:89
/builds/issue/drupal-3183766/vendor/phpunit/phpunit/src/Framework/TestResult.php:729
ERRORS!

Which shows the issue. Manually testing also seeing the issue.

Change fixes the issue for me so believe this one is good.

mradcliffe’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs issue summary update

Thank you for adding the tests and reviewing the issue @ian.ssu, @sushyl.

Thank you for reviewing the added tests and manually testing, @smustgrave.

I read the issue summary, but it was not clear to me what among the 3 proposed resolutions was the proposed resolution that was RTBC. I changed the status to Needs work only so that we can update the issue summary to clarify the proposed resolution.

The text changes should also be mentioned under User interface changes per Issue summary field - Issue Summary Template.

sushyl’s picture

Issue summary: View changes
Status: Needs work » Needs review

Thanks @mradcliffe,
Updating the Issue summary.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs issue summary update +Needs Review Queue Initiative

Good catch @mradcliffe

Solution seems clearer now.

quietone’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Postponed
Issue tags: +Usability, +Needs title update, +Needs tests
StatusFileSize
new8.56 KB
new8.31 KB

Thank you to everyone at Portland for working on this issue!

I am triaging the RTBC queue. I began by reading the title, Issue Summary and then the last few comments. The title could be improved, it should indicate something about the change. We need to consider that this is used in the commit message and needs to make some sense to someone doing some git archeology. #41 asked for changes to the Issue Summary in the User Interface section. That section is empty so that has not been completed. Also, this is making changes to the User Interface so before and after screenshots should be available from the Issue Summary. The latest screenshots here are from 2 years ago.

Issues that are changing the UI are to be tagged 'usabilty', I am adding that tag. Usability issues often need a usabilty review as well. That may not been needed but without screenshots I am not able to make a decision.

I then went back and reviewed the code and tested locally. While doing so I made screenshots and have updated the issue summary. The changed code does what it needs to and is working well. Yay! I did spot that the test is only testing the changes to the 'some' pager type. It should test all types and all text changes.

While the tests were running I read the comments. I see that #4 is addressed but I don't think that #24 has been. That is a totally different approach. It is also a reminder to us all to read all the comments first!

I am going to save the changes I made to the MR but set this postponed and ask the other committers.

quietone’s picture

Issue summary: View changes
Status: Postponed » Needs work
Issue tags: +Needs followup

After some time away and eating a meal I concluded there is no need for consultation. The way forward is to open an new issue to look into the change suggested in #24. This issue improves the user interface and I think that is more important than an ideal improvement, even if that improvement means removing the code added here.

johnv’s picture

Title: Views Pager - 0 Items is confusing » Pager option 'Items per page' with value 0 gives confusing summary, change to 'All'

dcam made their first commit to this issue’s fork.

dcam’s picture

The title was changed in #46.

I implemented @quietone's feedback and added a unit test, deleting the previous changes to the functional test.

The three primary pager plugins; Full, Mini, and Some; now have identical summaryTitle() functions. This repetition is painful and may only lead to more issues in the future if only one is changed again later. Frankly, I think the changes should go in PagerPluginBase instead of having it return "Unknown." Let outlier plugins like the None plugin override this sensible default. Just my $0.02.

Also, I think it's important to note that the proposed changes remove unique text from the Full and Mini pagers. Previously, the Full pager output a string like:

Paged, @count items

And the Mini pager output a string like:

Mini pager, @count item

The "Paged" and "Mini pager" text is now gone. I don't know that it matters, but it needs to be mentioned.

dcam’s picture

Status: Needs work » Needs review
adrianm6254’s picture

Issue tags: +Midcamp2025

I was able to apply the patch but the choices still seems a bit "clunky"

I suggest having 3 choices, "Display all items" which will do that and has no need for a pager. Then have Full and Mini pagers that are configurable.

smustgrave’s picture

Status: Needs review » Needs work

To discuss the feedback on #50, also was tagged for a follow up but don't see the issue for that.

binssss’s picture

The Drupal Contribution Mentoring team is triaging issues for DRUPALCON NARA 2025, and we are reserving this issue for Mentored Contribution during the event.

After November 19, 2025, this issue returns to being open to all. Thanks!

I performed Novice Triage on this issue. I am leaving the Novice tag on this issue because it seems we have the opportunity to refine the pager type messages, approach and also realign changes with the tests, It's also interesting to have a universal pager message that can handle offset.

binssss’s picture

Issue tags: +Nara2025

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.