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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

merlinofchaos’s picture

This is not currently possible.

dubitable’s picture

So, 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)?

merlinofchaos’s picture

No, Views 2 does not support that either.

dubitable’s picture

Whoops--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!

merlinofchaos’s picture

It'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.

dubitable’s picture

I'll give that a shot, m.o.c.--thanks for your feedback!

mrtoner’s picture

Version: 5.x-1.6 » 6.x-2.x-dev
Category: support » feature

Ran 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:

<?php if (!empty($title)): ?>
  <h3><?php print $title; ?></h3>
<?php endif; ?>
<?php foreach ($rows as $row): ?>
  <?php print $row ?>
<?php endforeach; ?>

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:

<?php if (!empty($title)): ?>
  <h3><?php print $title; ?></h3>
<?php endif; ?>
<?php $count = 0; ?>
<?php foreach ($rows as $row): ?>
  <?php print $row ?>
<?php
  $count++;
  if ($count == 5) {
    break;
  }
?>
<?php endforeach; ?>

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!

DeeLay’s picture

+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??

3CWebDev’s picture

+1 for this feature too.

ferrangil’s picture

+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) :)

dawehner’s picture

Afaik it is / would be able with the pluggable pagers, so only 3.x

SchnWalter’s picture

thank you...

dagmar’s picture

Title: Limiting total number of nodes.... » Limiting total number of items....
Version: 6.x-2.x-dev » 6.x-3.x-dev
Issue tags: +alpha-2 blocker

Lets try to implement this feature for the alpha 2 of views 3. Tagging.

dagmar’s picture

Status: Active » Needs review
FileSize
2.1 KB

Initial 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.

bleen’s picture

+1 for this option

dawehner’s picture

Status: Needs review » Needs work

I 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?

dagmar’s picture

Status: Needs work » Needs review
FileSize
2.85 KB

Thanks for testing it dereine!. Here is a new patch.

Again remember you need #652712: Pager settings are not stored that now is RBTC :)

dawehner’s picture

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

Works fine. And the code looks fine.

I would like to introduce a new tag.

ferrangil’s picture

I 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.

bleen’s picture

@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.

merlinofchaos’s picture

From 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.

dawehner’s picture

FileSize
2.98 KB

New version

bleen’s picture

@merlinofchaos

From a UI perspective, wouldn't it be better to have a total # of pages?

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.

merlinofchaos’s picture

No, there is already a pager for "unpaged with a limit".

merlinofchaos’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)
FileSize
2.85 KB

Actual patch applied differs slightly. Needs to be ported to 7.x along with pluggable pagers.

dawehner’s picture

Issue tags: -alpha-2 blocker

remove tag.

dawehner’s picture

dawehner’s picture

Status: Patch (to be ported) » Fixed

commited.

Status: Fixed » Closed (fixed)
Issue tags: -Needs tests

Automatically closed -- issue fixed for 2 weeks with no activity.