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.
I need to display 9 nodes per page, and also limit to only 10 pages (90 nodes)...
Can someone confirm that limiting to 90 nodes is currently not possible in Drupal5 or have I missed out something?
My next alternative is to work around using the default pager, pager_list functions.. Is this advisable?
Any help will be very much appreciated.
Comment | File | Size | Author |
---|---|---|---|
#25 | 268023-limit-number-of-pages.patch | 2.85 KB | merlinofchaos |
#22 | views-268023_0.patch | 2.98 KB | dawehner |
#17 | views-268023.patch | 2.85 KB | dagmar |
#14 | views-268023.patch | 2.1 KB | dagmar |
Comments
Comment #1
merlinofchaos CreditAttribution: merlinofchaos commentedThis is not currently possible.
Comment #2
dubitable CreditAttribution: dubitable commentedSo, a related question is, is this possible in Views 6? That is, can I limit the total amount of nodes returned (not just nodes per page)?
Comment #3
merlinofchaos CreditAttribution: merlinofchaos commentedNo, Views 2 does not support that either.
Comment #4
dubitable CreditAttribution: dubitable commentedWhoops--sorry, I meant Views 2, thanks for grasping that and correcting me.
Is this something that you'd be interested in including later on, or no?
Thank you!
Comment #5
merlinofchaos CreditAttribution: merlinofchaos commentedIt's never been a requested feature before, so as a feature requested it'd get very low priority.
I'd recommend that if you need view total size limitation, you use some kind of queue (such as nodequeue) as your criteria, such that there will only ever be 90 nodes to choose from. I don't know what the basis of your view is, but nodequeues are useful for being very precise with what is presented.
Comment #6
dubitable CreditAttribution: dubitable commentedI'll give that a shot, m.o.c.--thanks for your feedback!
Comment #7
mrtoner CreditAttribution: mrtoner commentedRan across this issue while looking for the ability to limit the number of records in a view. This won't directly work for you, ystanley, but it may get you started.
First, you'll need to override a views template. I don't know which one you'll need, but I chose views-view-unformatted.tpl.php. It contains the code for iterating through each of the records:
Copy the template into your theme folder. Rename it to include the name of your view. For example, mine became views-view-unformatted--recent-products.tpl.php. You'll find all the possible templates by clicking the Theme: Information link while editing the view. Click the Rescan template files to allow Views to see your new template.
Now, I edited my template:
I put the limit in
if ($count == 5) {
. By turning off the pager, even if there are more nodes returned than I specified in the Items to display setting, I'm only going to get one page with 5 on that page.I'll mark this as a feature request, though, merlin. Now you have two requests for this!
Comment #8
DeeLay CreditAttribution: DeeLay commented+1 on this feature request, it would be useful. I'm using views_attach to display the nodes of a certain type, and I would like to be able to limit the total number of nodes and have a pager. Unless there is a way to do that currently??
Comment #9
3CWebDev CreditAttribution: 3CWebDev commented+1 for this feature too.
Comment #10
ferrangil CreditAttribution: ferrangil commented+1 for this feature. Having 50.000 nodes with content and a views like "What is new" means a huge pager, and the views can also be called "What is old" (you just need to check the latest page) :)
Comment #11
dawehnerAfaik it is / would be able with the pluggable pagers, so only 3.x
Comment #12
SchnWalter CreditAttribution: SchnWalter commentedthank you...
Comment #13
dagmarLets try to implement this feature for the alpha 2 of views 3. Tagging.
Comment #14
dagmarInitial patch. You need to apply #652712: Pager settings are not stored this to get this working. At this moment this issue is marked as "Needs work", but It worked for me, so if you can test both patches, I will appreciate.
Comment #15
bleen CreditAttribution: bleen commented+1 for this option
Comment #16
dawehnerI set up a view with items per page of 2 and total of 5. But on the last page, there are still displayed 2.
I guess this should be fixed, sry :).
I'm not sure how to fix it, i guess we have to use function query() for the pager plugin, or?
Comment #17
dagmarThanks for testing it dereine!. Here is a new patch.
Again remember you need #652712: Pager settings are not stored that now is RBTC :)
Comment #18
dawehnerWorks fine. And the code looks fine.
I would like to introduce a new tag.
Comment #19
ferrangil CreditAttribution: ferrangil commentedI have an alternative "solution" which may work for several cases.
For example, I was listing the recent nodes on my site, which has 80.000 nodes. Then, the pager was huge. Adding a Filter by the creation date allows to only list nodes added during last month, so the pager is much short. You can't limit the number of pages, so it's not exacly what we were discussing previously here.
Comment #20
bleen CreditAttribution: bleen commented@ferrangil ... that is certainly a good solution in certain use cases but I could rattle off a dozen use cases that this does not help with. Fundamentally we should be able to limit the total number or rows returned by a view...
example use case: I want a view that shows the 4 (and only 4) most recently created nodes, but I want to show 1 per page with a pager.
Comment #21
merlinofchaos CreditAttribution: merlinofchaos commentedFrom a UI perspective, wouldn't it be better to have a total # of pages? The administrator shouldn't have to caluclate that 5 pages with 25 items each is 125 items. We can do that.
Comment #22
dawehnerNew version
Comment #23
bleen CreditAttribution: bleen commented@merlinofchaos
What about the use case where I want to limit the view to 10 records but I'm not using pages? In that case would I have to turn paging on, set the items per page to 10 AND set the total number of pages to 1? So I need to set three settings to limit my view to 10 rows? But now I have a pager being rendered.... hmmmm
It's certainly possible that I'm missing something but this is a use case we should definitely consider.
Comment #24
merlinofchaos CreditAttribution: merlinofchaos commentedNo, there is already a pager for "unpaged with a limit".
Comment #25
merlinofchaos CreditAttribution: merlinofchaos commentedActual patch applied differs slightly. Needs to be ported to 7.x along with pluggable pagers.
Comment #26
dawehnerremove tag.
Comment #27
dawehnerDepense on http://drupal.org/node/586668
Comment #28
dawehnercommited.