I've got a view with a pane display with an "Allow settings: All" and the number of items is set to 10.
I've created a page and added a the display pane to it, with settings "Use different pager settings from view settings" checked, "Use pager" unchecked, and the number of posts to display set to 1 in order to show only the first element on this pane, but I get as many post as I set on the view, not the setting of the pane.

I'm using
views 7.x-3.0-rc1 build on 2011-Jun-17
ctools 7.x-1.0-rc1 build on 2011-Jul-28

Can anybody help me?

Comments

kardave’s picture

I had the same strange behavior and found that if a View display use overriden settings for paging and number of displayed items, that display is ignores the "num posts" that panel sends.

Is it a bug, or panels/ctools/views is designed this way?

dkingofpa’s picture

Version: 7.x-1.0-rc1 » 7.x-1.x-dev
Priority: Normal » Major

The panel's "Custom pager settings: Num posts" value doesn't look like it's getting applied. This worked in D6 but is now broken in D7. Bumping priority to major as it involves broken functionality, but the module works otherwise.

Steps to reproduce:

  1. Create a display in views that has a pager set to "Display all items"
  2. Make note of how many items are listed in the view
  3. Add that views display to a panel
  4. Go into that panel's settings and check "Custom pager settings: Use different pager settings from view settings"
  5. Make sure "Use pager" is not checked (don't want to use a pager for this panel)
  6. Make sure "Num posts" is set to a number less than the total list from step 2 above
  7. Save
  8. View panel

The panel shows all items when it should be limiting the output to the number specified in the panel settings.

jdcc’s picture

Status: Active » Needs review
StatusFileSize
new665 bytes

I just did a bit of research into this.

The pager for the view isn't initialized before a call to get_items_per_page(). The view class pushes this call out to the view instance's pager, but as there's no pager yet, it returns NULL. This NULL leads to ctools selecting the 'none' pager instead of the 'some' pager for the view, and the 'none' pager only allows for the 'offset' option - not 'limit' - so the limit gets ignored.

I've attached a one-liner patch that fixes the issue. The argument could be made that a fix belongs in Views instead of ctools, but I don't know enough about either to make that decision.

merlinofchaos’s picture

Status: Needs review » Closed (duplicate)
dalin’s picture

Title: Num posts on pane config is ignored » Num posts on pane config is ignored if the view is configured to show all items
Status: Closed (duplicate) » Needs review
StatusFileSize
new748 bytes

No I think the problem still exists - specifically if the view is configured to show all items, but the pane is configured to show a specific number with no pager. That other issue fixed a few other combinations, but not this one.

In short I think the line that this patch alters should mean: If the pane is not set to use a pager, and the view is not using a pager, then set the pager style based on the calculated number of rows (which uses the pane's number of rows to override the view's unlimited setting). I was hoping the plain-English would be easier to understand, but perhaps not; Just see the patch.

David_Rothstein’s picture

StatusFileSize
new692 bytes

The patch in #5 has an issue - if the view is configured to have a full pager but the pane is configured to have no pager, the patch prevents the view from being overridden and therefore the pager is displayed when it shouldn't be.

So we need to preserve that behavior but also fix the bug mentioned in #5. The end result is that when the pane is configured not to have a pager:

  1. If the view has a full pager, we need to override it.
  2. If the view is configured to show all items, we need to override it in the case where the pane is configured to show only some items.
  3. If the view is configured to show some items, we need to override it in the case where the pane is configured to show all items.

In short, we always need to run this code, so that's what the attached patch does :)

Note: Similar code exists in plugins/content_types/views_panes.inc, and my guess is that should be changed as well, but for now the patch only touches views.inc since that's where I ran into the bug.

drupalfan2’s picture

Issue summary: View changes

Is this patch still necessary for latest Drupal 7 versioin?

edgarmxl’s picture

StatusFileSize
new1.41 KB

This simple update was done on having in consideration David_Rothstein's 1254256-6-ctools-fix_pager_selection.patch but extending it on view_panes.inc as well

joelpittet’s picture

Status: Needs review » Fixed

Thanks @edgarmxl for the updated patch, I've committed this to the dev branch

Status: Fixed » Closed (fixed)

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