Problem/Motivation
There is no way for a site to set how many items can be displayed using pager. Currently the default is 10 items.
Proposed resolution
It would be nice to allow the site admin or end user to set how many items they want to display per page using pager.
Remaining tasks
Decide on the proper implementation.
Four methods have been proposed.
- Allow the site admin to set the number a items to view per page using pager. Also increase the default to 50.

- Allow the end user to set the number of items per page when using pager.

- Abandon the pager concept wholesale and aim for infinite scroll: #1488866: Redesign pagers for administrative lists.
- Go from a number based pager to alphabetical based.

User interface changes
Admins or users will be able to set a number of items to display per page using pager, and alphabetical list, or an infinite scroll approach.
Questions:
1. Which of these methods, or some combination of them, is preferred?
2. What numbers should be used for min/max values, if any?
3. Where do we want the validation performed?
Original description
It will be nicer to have an option that users can select by themselves how many records can be displayed on a page, such as 5, 15, 50, or all records. This feature is actually very common.
The best place I have thought is to add the feature to the pager.
I have implemented this feature on my site one year ago when I was new to Drupal. As it requires many changes not only in pager.inc but also somewhere else, I expect that Drupal developers can do a better job than me.
I look forward to see this common feature in Drupal 4.7.
| Comment | File | Size | Author |
|---|---|---|---|
| #79 | pager-options.png | 54.42 KB | johnv |
| #59 | List-Pager.png | 7.34 KB | kattekrab |
| #54 | pager-39954-54.patch | 6.37 KB | NROTC_Webmaster |
| #52 | pager-39954-52.patch | 6.37 KB | NROTC_Webmaster |
| #52 | pager-interdiff.txt | 6.83 KB | NROTC_Webmaster |
Comments
Comment #1
sepeck commentedrather then expect others to do a better job, please attach your patch for others to examine your appraoch and comment yes/no/ ideas.
Comment #2
thinker commentedI would love to. However, as I said, my implementation was very old based on Drupal 4.4.X, I don't think it will be useful, helpful or worth at all for you people to look at it.
Well, if you think this feature is really really hard to be implemented, I may re-write it based on Drupal 4.6.X and let you examine my code. However, I don't think it will save any time or energy for both you and me in order to put the feature in Drupal 4.7.
Let me know your comments.
Thanks,
Comment #3
magico commentedComment #4
dwwbump: this is a ubiquitous interface outside of drupal, and incredibly handy. it'd be *really* nice to have this for D6. anyone available to work on it? my hands are way too full as it is already... :(
Comment #5
dwwi could see problems with running out of memory, especially if people used 'show all' carelessly (e.g. on the front page of d.o)... if that's the only objection, i think we can come up with some solutions. worst case is we add a new permission for using this functionality. better yet is some fine-grained settings to contol limits for different pager queries (gee, if only we had a query builder and each query had a unique query id). ;) perhaps in the code, where we currently hard-code the value, we'd just hard-code the upper limit and default value for that particular pager query. or some combination of the above.
one of my primary motivations is for the issue queue pager. by default, 20 issues seems ok, but in some cases it'd be really handy to bump that upto 100, or even do a "show all" for a given project. thing is, this isn't a site-wide setting that makes sense, nor would it work as a per-user setting in your profile. i'd want to see different things depending on what issue queue i was looking at. always having a tab open on my profile page to keep changing the setting would drive me insane. in theory, i *could* add some custom crap to the pagers in project* to handle this as a special case, but i'd rather just put that effort into the D6 core pager...
anyone else with me? ;) any chance this is going to get committed if i come up with a nice solution? i'd hate to work like crazy on this, only to run into a veto from the D6 maintainers...
Comment #6
gábor hojtsyYes, I was clicking on this link in your mail to come and share my performance concerns. What if someone asks for a few hundred nodes on the tracker pager for example? Tracker is already slow enough as far as I see. So limits should be in place. Otherwise it is indeed better to have this setting in the URL (against my point expressed on 2005-10-12), because you can hand around links that way, which would list the same number of things on the pager (maybe if the user has the permission, if this is bound to permissions).
Comment #7
kattekrab commentedHello!
:)
It would be great to add a user choice widget to pager so that we can choose from some options (5, 10, 15, 100 or Show All) - and seeing that it didn't happen for 4.X, 5 or D6 - can it happen for D7? Pretty Please?
I realise it can put load on the server but ways to mitigate that risk were pointed out above.
Also - one query that delivers 1000 results saves another 20 queries looking through pages that deliver 50 results each.
Give me the option to grind my server to a halt. Restrict it to admin users, whatever... but really, it would be very very useful.
Comment #8
dwwSadly, no chance for D7 now. :( This is a new feature, and we're long past feature freezes and exceptions for D7. This will have to happen in D8 if it happens. I've got no time to work on it anytime soon, so I'm unassigning myself, too.
Comment #9
kattekrab commentedWhat if someone submitted a patch? Would there be a chance?
Comment #10
dwwNo chance, sorry. A feature freeze means that the only patches accepted to Drupal 7 core are bug fixes at this point. If they kept allowing new features, we'd never stabilize the release and be able to ship 7.0.
Comment #11
kattekrab commentedFair enough! :)
So if we do submit a patch (already halfway there, for our own use) to Drupal8 (once that's open) is there any chance it could get backported to 7.x or something? Or should we be looking at just maintaining this for our own use?
Comment #12
webchickDries and I have yet to hash out what features exactly from D8 could get back-ported, but since this implies UI changes I'm not sure we could do it. As a book author and documentation team member, I'm /very/ sensitive to invalidating screenshots and documentation.
For now, though, I'd like to focus on just getting D7 out the door. :)
Comment #13
cafuego commentedWell, so that there's no duplication of effort for 8.x, here's my 7.x patch that allows for the 'show all' option on pagers.
It strikes me that it might be possible to work this into a module, so it could be a contrib thing for D7.
Comment #14
cafuego commentedI have reworked the patch, so it works as I think it should. Clicking 'show all' will suppress all but the '« first' and 'last »' links now. It's set via the url
?all=1so it will work in links.As indicated by Gábor, 'show all' can cause a lot of load on a system if a giant list of stuff is loaded (and then themed, possibly with sub-queries) so I've added a permission. There is not currently a warning on that permission, though.
If a user without this permission clicks an
?all=1link, it will happily degrade to showing the first page of a normal pager.Attached is the patch against git 8.x.
Comment #15
mattyoung commentedsubscribe
Comment #16
kattekrab commentedStatus Ignored? What does that mean?
Comment #18
cafuego commented#14: pager-39954-13.patch queued for re-testing.
Comment #20
cafuego commentedFixed the exceptions in the test bot by properly initialising variables.
Comment #21
michaelfavia commentedPatch applies cleanly and works as expected. Neither coder nor my cursory review find any style issues. I can't speak to this as a desired feature in core but if it is it seems to fit the bill well enough. ;)
Comment #22
xjmThis seem like a reasonable feature. Thanks for working on the patch! I have just one VERY minor note on code style:
I think these lines are 1-2 characters too long, so let's wrap the last word of each onto the next line.
Also, note that the Drupal 8.x patch will need to be rerolled, because the core directory structure for Drupal 8 has now changed. (For more information, see #22336: Move all core Drupal files under a /core folder to improve usability and upgrades). When the patch has been rerolled, please set the issue back to "Needs Review."
Tagging as novice for the task of rerolling the Drupal 8.x patch (preferably with the line rewrapping mentioned above).
If you need help rerolling this patch, you can come to core office hours or ask in #drupal-gitsupport on IRC.
Comment #23
kattekrab commented(my first patch - under supervision)
Updated the patch to apply to latest Drupal 8.x and adjusted comments as suggested by @xjm.
Comment #24
xjmThanks @kattekrab, it looks great.
Just noticed this summary is two lines. I've fixed that in the attached patch.
Now, let's have one more person test out the patch and add some screenshots of how it works. Thanks!
Comment #25
xjmOops. Darn dreditor. :)
Comment #26
kattekrab commentedInstalled D8 with patch applied, used devel to generate 1000 nodes. It certainly takes a moment to display them, but it displays 1000 nodes with the option to click back to the start or end of a pager based display, instead of show all.
In other words. It works!
Three screenshots attached showing
Permissions
"Access "show all" fuctionality in pagers "
[which has a typo - hooray - my 2nd patch will follow this.]
Content list
50 devel nodes showing
" 1 2 3 4 5 6 7 8 9 … next › last » show all "
Content list
1000 devel nodes showing
" « first last » "
Comment #27
kattekrab commentedMy 2nd Patch (tm)
Applied xjm comments changes from #24 and fixed typo in the permission.
New screenshot with typofix shown attached.
Comment #28
kattekrab commentedRemoved stealth whitespace.
Added description to the permission.
Comment #29
kattekrab commentedAnd just for OCD sake - a screenshot showing the permission description is attached.
I've also tested a user without permission to access the show all, and huzzah - the 'show all' does not show. Likewise editing the URL manually to show all (eg node&all=1) does not show all.
Comment #30
tayljay commentedI think that it would be a very useful feature to be able to nominate how many or for all records to be displayed on a page. It would make it much easier when searching - for example I often have to search through pages of users which would be made much easier if I could just do a find once on one page rather than on ten. Great idea : )
Comment #31
xjmSo I dreamed about this patch last night. Seriously. Anyway, I realized the behavior after you have clicked "show all" is not intuitive--"first" and "last" don't make any sense. What I'd prefer is a link to switch me back to the previous view. Maybe just one link to toggle it back, "show X" (50 for now), and it by default uses the last page you were on when paging. What do you think?
Comment #32
kattekrab commented@xjm - when I grow up, I wanna dream about patches too! :)
But yes, I tend to agree. I'm just not sure of a solution.
So... based on the cursory research I just did - here's a super simple approach.
Add "show less" to the page that shows all - and link back to the first page of results.
Mockup attached.
Perhaps some usability / ux folks could weigh in with suggestions / point to a better approach?
Research
So here's a quick cursory glance at some pagination UI design patterns.
http://ui-patterns.com/patterns/Pagination
http://www.cxpartners.co.uk/cxblog/pagination_a_lazy_interface_decision_...
http://www.smashingmagazine.com/2007/11/16/pagination-gallery-examples-a...
http://ux.stackexchange.com/questions/789/pagination-best-practice
http://www.onextrapixel.com/2010/11/03/15-ui-design-patterns-web-designe...
Here's a Drupal example
http://mundanity.com/pagination-example
Comment #33
webchick(Sorry, please don't hit me, but...)
Hm. One thing I observe from all of those screenshots is that none of the pagers referenced there have this "Show all" feature. :\ So while the feature itself sounds useful, I'm not sure it should be coupled with the pager.
Comment #34
kattekrab commentedThis one shows the "show all" link :)
http://drupal.org/files/d8-pager-39954-showall.png
Comment #35
webchickSummary of IRC discussion:
Yeah, I don't see how this is going to fly.
What this essentially does is make a global "flag" that anyone in the admin role is exempt from and so is any user I want to have this feature anywhere else on my site, that says in ALL instances of a pager, regardless of how many elements are in that pager and what those elements are, there will be a "Show all" link. Both in the case of a small list of small things, like 120 aggregator items AND in a list of large things like a list of 50,000 nodes with 30 fields a piece each of which requires 170 database queries to build).
This "Show all" element needs to be contextual, and used on a per-pager basis, IMO.
26 days to next Drupal core point release.
Comment #36
cafuego commentedI agree that it's probably not a good idea to have a 'Show All' link on all pagers on all sites. However, there is not currently a way to allow contrib modules to affect the pager beyond theming it, so some sort of change must be made to core to allow this functionality be added.
A different way to address this issue is to allow PagerDefault to be pluggable (See the second half of #778050: Add support for database hints and make PagerDefault properly pluggeable) so that contrib modules can implement their own pager queries and thus their own pager functionality.
I've also written a patch (attached) that allows the setting of a global pager limit. Currently the default defined in pager.inc is 10. This patch changes the default to 50 (which is what admin/people and admin/content were using anyway) and allows site administrators to change this default to any number between 10 and 1000. It expressly warns about performance if a number > 200 is chosen.
This patch changes the pagers in node.admin.inc and user.admin.inc to use th new user-configurable default. Other pagers in core are not affected, unless they didn't specify a number of items to begin with.
Comment #37
cafuego commentedBugger, forgot to set the patch to needs review. Reattaching.
Comment #38
xjmPlease don't kill Mr. Newline!
(Need a newline at the end of the file.)
In general, this approach seems better, and it's a definite improvement over the current situation without the drawbacks above.
From reading the patch, it doesn't look like end users can configure it. I think I'd probably expect the option to show up next to the pager, rather than buried in the system config forms somewhere. Maybe that could live in contrib, though, given this patch.
Screenshots would be helpful here as well.
Comment #39
xjmOops, didn't mean to do that. :)
Comment #40
kattekrab commentedDid someone say screenshots?
Comment #41
kattekrab commentedAttached screenshots.
Maybe we should tell the user that numbers between 10 and 1000 are accepted...
Comment #42
webchickI guess if we wanted to keep this a global thing, another option could be setting the threshold for number of records beyond which the "Show all" link is hidden as an option.
variable_get('pager_show_all_record_threshold', 150)orvariable_get('pager_show_all_page_threshold', 3)or something. This really only comes up in situations where the number of records displayed is just more than will fits.Comment #43
yoroy commentedBesides the 'show all' option, how is this different from the 'Number of posts per page' setting already available under config/site-information?
I don't see it, what I'm missing here?
Comment #44
xjm#43: That setting doesn't have any effect on the pager, to my knowledge. Separate functionality. That's only used for the front page and for term listings (teaser pages). The pager on the other hand is used for all manner of lists, like are found on
admin/content,admin/people, etc.However, we probably should make it obvious to users what the difference is, and maybe put the two together on the same form?
Edited to be less nonsensical.
Comment #45
yoroy commentedAh, thanks. You are right, listings in admin go to 25 or 50. Hmm, so the existing one is for site front-end content listings maybe?
I think the only way to make this obvious is to treat these as *the same* thing first :) The mental image I got from this thread was more like this:
Wouldn't that be a nicer gesture than moving into an admin setting? Either way this seems like merely a nice to have and I'm not sure it's up to core to provide it out of the box.
The mismatch I had with that existing setting tells me we need a clearer picture of what's already defined for pager/result list lengths before extending the feature.
Comment #46
cafuego commentedThere's isn't really anything. All pagers in core (minus the front page and term list) and contrib use whatever who wrote said feature thought would be appropriate. If nothing is specified, the pager defaults to 10 items per page.
An exception is the admin taxonomy term list, which lists 100 items per page. It references a variable that would in theory be able to adjust that size, except there's no UI to set said value. See #1332534: Long hierarchy taxonomy memory exhaustion; pager problem.
Either way, a way of changing the list size is what I want. I'm not particular bothered about how we accomplish that ;-)
Again, that fine. But if core doesn't provide a way of changing the pager page size, it should provide a way for contrib to do this. Then any number of pager modules could provide any number of pagers, making all users happy :-)
Comment #47
kattekrab commentedThis seems to be languishing again... any progress?
Comment #48
NROTC_Webmaster commentedHere is the patch applied to the latest version without killing the newline.
Comment #49
Bojhan commentedCan we have a screen of the latest screen?
Comment #50
NROTC_Webmaster commentedHere is a screenshot and an updated patch.

Comment #51
xjmThanks @NROTC_Webmaster!
Tagging for an issue summary to summarize the possible directions for this issue. We should probably pick one before proceeding (that's why I think this issue got stuck before).
Code review follows. Note that below I pointed out things to fix if we keep the form that exposes this config to the administrator (with the style notes about those lines), but as stated I personally think it would be better to nix all the lines related to the form. :)
Grammar nitpick: These should be "The number of items" rather than "The amount."
Should be
elseifrather thanelse if. Reference: http://drupal.org/coding-standards#controlstructAlright, so this host of different possible magic values is a little confusing. Not sure how to address it but that's a lot of special cases. It's also not clear in the method why all this is the case, so at the least I'd want some @see explaining why. Is there any way we can make the behaviors more explicit, though?
Edit: I see now it's from the protected variable on the class, so let's clarify that at least. Still not sure about the magic "0 vs. NULL vs. FALSE," though.
Aside (super nitpick) the word "passed" doesn't make sense in the @param. Given the current logic, I'd make the @param:
An integer specifying the number of elements per page. If 0, the default from the 'pager_items' configuration variable is used. If NULL or FALSE, the pager is disabled.So we are going from a default of 10 to one of 50, correct?
Form constructor for the pager settings form.It should also have @see to its submission and validation handlers. Reference: http://drupal.org/node/1354#forms
We should maybe use a number element for this once #1174640: Add new HTML5 FAPI element: number is in!
Do we need the second sentence here when we have the warning? Or, maybe we don't need the first sentence.
This should read:
Form validation handler for system_pager_settings().. Reference: http://drupal.org/node/1354#formsThese seem kind of magic-numbery; maybe we should define some more constants?
Comment #52
NROTC_Webmaster commentedxjm,
Along the same lines I'm updating the patch according to your recommendations.
For #7 since we are using the number field do we want to add the min/max values here?
[edit] - the number field didn't work on my site. I don't think the patch was actually merged yet.
For #8 since we are giving a description to the input field I think it is essential to have the first sentence, but we can probably live without the second one since it is given on the validation.
In regards to #10 is there a specific reason we would not want the admin to "allow" the number to be less than 10? While I can't think of any specific examples where it may be useful having the option is always my preference. Maybe just a warning that it might hurt the user interface?
I don't know how to add the issue summary at the top but here are the things I see.
Issue Summary
Problem/Motivation
There is no way for a site to set how many items can be displayed using pager. Currently it is 10.
Proposed resolution
It would be nice to allow the site admin or end user to set how many items they want to display per page using pager. Also increasing the default limit to 50.
Remaining tasks
Decide on the proper implementation.
Two methods have been proposed. Allow the site admin to set the number or the end user to set it when viewing a page.
User interface changes
Admins or users will be able to set a number of items to display per page using pager.
Questions:
1. What numbers should be used for min/max values
2. Where do we want the validation performed?
Comment #53
NROTC_Webmaster commentedActually use this version.
Comment #54
NROTC_Webmaster commentedLets hope that this is the last one.
Comment #55
yoroy commentedPagers are pretty much antique by now :) I'd much rather abandon the pager concept wholesale and aim for infinite scroll: #1488866: Redesign pagers for administrative lists.
Comment #56
cafuego commentedIsn't infinite scroll 100% dependent on javascript?
Comment #57
xjm@NROTC_Webmaster, you can put the issue summary in the issue summary (click the "Edit" tab at the top of the issue). :) Also, it would be good to have more details in the proposed resolution about the different approaches that have been suggested and the implications of each.
Comment #57.0
NROTC_Webmaster commentedUpdated issue summary.
Comment #57.1
NROTC_Webmaster commentedUpdated issue summary.
Comment #57.2
NROTC_Webmaster commentedUpdated issue summary.
Comment #58
NROTC_Webmaster commentedThe issue summary has been updated.
Comment #59
kattekrab commentedAlso, infinite scroll does not help when you are trying to use the browser search function to find something in a long list of stuff.
But - I agree that the numbered list of pages also isn't generally useful in trying to guess where in a long list something might be. Pages divided alphabetically are sometimes better for that kind of thing... as in mailman.
Comment #60
salvisWould select all work with infinite scroll? What about graceful degradation for non-JS browsers?
It seems that technology moves faster than this issue, and because we won't settle for anything but the perfect solution, we'll never see an implementation. For administrative pages (where this is really needed!), I'd be perfectly happy with having the limit in the URL.
Comment #60.0
salvisUpdated issue summary.
Comment #60.1
NROTC_Webmaster commentedAdd alphabetical sort to the options
Comment #61
salvisUntil we see a solution in core, the Pager Limits module does just that for D7, without requiring any core patches.
Comment #62
amyhribar commentedissue summary exists
Comment #63
cole.erickson commentedWhile the latest patch adds a menu for changing the number of posts for the pager, it does not actually cause a change in the number of posts displayed. (for me, anyway)
I went to Configuration >> Pager and changed the number of posts in the appropriate field to 4, hit the save button, cleared the cache, and checked the /node page and it still pages at Drupal's default of 10 posts.
Comment #63.0
cole.erickson commentedUpdated issue summary.
Comment #63.1
xjmUpdated issue summary.
Comment #63.2
xjmUpdated issue summary.
Comment #64
kattekrab commentedWe missed feature freeze on this - but with views now in Core - perhaps the pager issue went somewhere else?
Comment #65
kattekrab commentedoh hello Pager issue.
Can we revisit this again now?
Comment #65.0
kattekrab commentedUpdated issue summary.
Comment #79
johnvThis is solved in ITMT in D11 (and before?)
See attached screendump.