Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In the Pager, there is an option for "Items to display". The description for it reads: "The number of items to display. Enter 0 for no limit."
If you put 0 in the field, it shows the text "Display a specified number of items | 0 items". This might be confusing for the user, it should be showing 0 items, instead it shows all of them. Perhaps change it to ""Display a specified number of items | all items" when user inputs 0 in the field?
Comment | File | Size | Author |
---|---|---|---|
#17 | pager-all-items_after_patch-1817442-17.PNG | 9.49 KB | Akanksha92 |
#16 | interdiff-13-16.txt | 7.14 KB | elaman |
#16 | pager-all-items-1817442-16.patch | 4.05 KB | elaman |
|
Comments
Comment #1
dawehnerI agree that this can confuse people, even it should be actually better to use the none pager instead.
Comment #2
Ignigena CreditAttribution: Ignigena commentedThis is limited to when the pager is manually set to "Display a specified number of items" and the value is set at "0". When creating a new view, if one types "0" in the "Items to display" option, Views will automatically set the appropriate pager setting to "Display all items" which shows a less confusing "Display all items | all items" message.
I would agree that it's confusing, and in the case the user does manually set the pager to "specified number" it might be better to have Views automatically switch the pager type back to "Display all items" for convenience if the "number of items" has been set to "0".
In the meantime, I've rolled a patch which will simple change the displayed language to be less confusing as proposed by the author. "Display a specified number of items" will now show "All items" if the value is set to 0 versus "0 items"
My solution was just to check $this->options['items_per_page'] for a "0" value and return the appropriate language.
Here's the code change within the class views_plugin_pager_some extends views_plugin_pager inside views_plugin_pager_some.inc:
Tested on a live installation and everything seems to work as expected.
Comment #3
Ignigena CreditAttribution: Ignigena commentedComment #5
Ignigena CreditAttribution: Ignigena commented#2: pagerallitems-1817442-2.patch queued for re-testing.
Comment #6
lyricnz CreditAttribution: lyricnz commentedIf you want to make this change, you should make it for all relevant pagers (full, mini, some).
Comment #7
lyricnz CreditAttribution: lyricnz commentedThe patch should also handle pagers with offsets properly - emitting 'All items, skip @skip'
Comment #8
lyricnz CreditAttribution: lyricnz commentedActually, since all four pagers use the same logic, it may be cleaner to add a utility method, then call it from each. However, in order to preserve full translate-ability that would mean dynamically constructing the string to be translated, which is probably bad for discoverability.
Comment #9
lyricnz CreditAttribution: lyricnz commentedHere's a patch that provides "All Items" messages on full/mini/some pagers. The changes for each look like (ignoring whitespace):
Comment #10
codi CreditAttribution: codi commentedApplied to HEAD and works as described!
Comment #12
dandaman CreditAttribution: dandaman commentedComment #13
dandaman CreditAttribution: dandaman commentedRe-rolled the patch with the current path of the Views plugins.
Comment #14
dandaman CreditAttribution: dandaman commentedComment #15
Chris Matthews CreditAttribution: Chris Matthews commentedThe views path is now: views/plugins/...
Comment #16
elaman@chris-matthews re-rolled the patch, based on your comment.
Comment #17
Akanksha92 CreditAttribution: Akanksha92 commented@elaman the patch looks good. The patch applied to the module successfully. Please find the attached screenshot for the same.