Currently users can enable and disable pager on a view pane on the edit panel page, however they can't change which pager type to use. In this case, if you want to display VIEW A on 2 pages, one with a full pager and one with a mini pager, you will need to duplicate the view display.

This patch adds the ability to override the pager type within a panel. To test this:

1) Enable Panels, Views, and Views Content Panes
2) create a view that shows content in teaser mode
3) add a content pane display
4) Under "Pane settings" -> "Allow settings" check the boxes "User pager" and "Pager type".
5) save the view.

6) Create a panel with a node context (or enable and edit the "node template" panel)
7) Create a new variant, and add the newly created view pane to your panel.

At this point, you should see a dropdown box called "Pager type" if the checkbox "Use pager" is checked.
Change the pager type to a different pager type as defined in your view, then save.

You should now see the pager of the view follow the pager type of the panels chosen.

Hope this helps!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

uq created an issue. See original summary.

uq’s picture

Status: Active » Needs review
rivimey’s picture

Hi, I've had a brief look at the code. Overall it's looking good, and I support the use-case and the way the problem has been solved. Thanks!

I would love it if you could implement some 'simpletest' test cases for this area. Ctools is very weak on such things and I have been trying to write more tests, but there is a lot of code!

There are a few specific comments below:

  1. +++ b/views_content/plugins/content_types/views.inc
    @@ -11,6 +11,7 @@ if (variable_get('ctools_content_all_views', TRUE)) {
    +      'set_pager_type' => 'full',
    

    Here, and line 320, we have 'set_pager_type'; elsewhere we have 'use_pager' and 'pager_type':

    To reduce cognitive load, would it be possible to reduce the variants by changing 'set_pager_type' to 'pager_type', or similar?

    It would be good to include some comments describing these keys, their possible values and their relationship to each other.

  2. +++ b/views_content/plugins/views/views_content_plugin_display_panel_pane.inc
    @@ -534,6 +536,10 @@ class views_content_plugin_display_panel_pane extends views_plugin_display {
    +      if ($conf['pager_type'] && $pager['type'] != 'none') {
    

    The $conf['pager_type'] should be checked for existence before use, unless you can guarantee it exists by this point.

    Plausibly, consider hardening != to !== for 'none'

uq’s picture

FileSize
5.4 KB

Thanks for the feedback!

The original patch contained a bug which caused the pager showing up in the view when "Use pager" checkbox is unchecked within the pane setting. I fixed that and modified the patch as suggested.

rivimey’s picture

Thanks for the updated patch, and great that you found the bug.

It would be much easier to accept the patch if you could include some simpletests for the pager functionality....

Just one point in the new patch:

+++ b/views_content/plugins/views/views_content_plugin_display_panel_pane.inc
@@ -534,6 +536,10 @@ class views_content_plugin_display_panel_pane extends views_plugin_display {
+      if ($conf['use_pager'] && isset($conf['pager_type']) && $conf['pager_type'] && $pager['type'] !== 'none') {

This line is over the 80 char soft-limit, and would benefit from the sub-expressions being grouped. I know mathematically it works, but visually it's not clear unless you examine it carefully.
IMO putting the 2nd,3rd expression on a new line, and the 4th on a subsequent line, would help there.

Feel free to do likewise on other lines as appropriate :-)

darrenwh’s picture

Status: Needs review » Needs work
+++ b/views_content/plugins/content_types/views_panes.inc
@@ -442,7 +463,7 @@ function views_content_views_panes_content_type_edit_form($form, &$form_state) {
+  $keys = array('link_to_view', 'more_link', 'feed_icons', 'use_pager', 'pager_type',

This array would benefit with being broken into individual lines as its drifted over the 80 char line limit.

ie:

$keys = array(
    'link_to_view',
    'more_link', 'feed_icons',
    'use_pager',
    'pager_id',
    'items_per_page',
    'offset',
    'path_override',
    'path',
    'arguments',
    'fields_override',
    'exposed',
  );