Pager in a block

bittindm - September 5, 2007 - 00:30
Project:Dynamic Views
Version:5.x-1.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

I'm trying to get the pager show up in a block (Dynamic Full Node view type ). Should a pager show automatically when the [More]? Link option is selected for blocks? Do I need to insert any special code to display it?

I see the setup working fine with a pager on the full page view as described in Use Case #1 from your documentation. Just wondering if it's possible to have the block by itself elsewhere on the site with a pager as well.

Thanks in advance.

#1

sarvab - September 5, 2007 - 05:04

Yes, you can use this just in a block, but you need to do two things to get it to work, 1) Enable "View More" in your view settings and 2) Enable pager enabled block of your view on the block admin page (its a duplicate of the original block allowing for pagers)

Hope that does it for you!

#2

bittindm - September 5, 2007 - 18:30

Thanks for the reply, but maybe I'm still missing something. When I created the view, I enabled block creation and tried both Dynamic Teaser List and Dynamic Full Node each time with "More" box checked. I don't see any blocks specifically labeled "pager enabled" but I did see a version of the block prefixed with "Dynamic: " which I placed in the right sidebar. No pager but the nodes are showing as expected with a normal block. Is there somewhere else that I should check for "pager enabled" blocks?

Do I possibly need to add something like the following which I used on Views pages to get the pager to show in the footer:

<?php
print theme('pager');
?>

Could it possibly be something theme related or a conflict with another module? Any help is very much appreciated as this will help complete a major piece of functionality I've been working on for far too long.

#3

sarvab - September 5, 2007 - 22:14

Your right about it being called Dynamic block instead of Pager enabled. And thats all you should have to do to get a pager enabled block to show up there. Could you give me an export of your view and I'll check it out here.

#4

bittindm - September 6, 2007 - 00:14

This is what I've got for a test view. You'll see some CCK fields and one unexposed filter that I'm using to select the node type. Is it okay to use a filter like that with dynamic views? This setup does show the pager just fine for the page view, just not in the block.

Let me know if you see anything weird.

Thanks again,
Dave

<?php
$view
= new stdClass();
 
$view->name = 'Nursery_Issues_Test';
 
$view->description = '';
 
$view->access = array (
 
0 => '3',
);
 
$view->view_args_php = '';
 
$view->page = TRUE;
 
$view->page_title = 'Support Requests and Bug Reports';
 
$view->page_header = '';
 
$view->page_header_format = '1';
 
$view->page_footer = '';
 
$view->page_footer_format = '2';
 
$view->page_empty = '';
 
$view->page_empty_format = '1';
 
$view->page_type = 'dynamic_node';
 
$view->url = 'issue-test';
 
$view->use_pager = TRUE;
 
$view->nodes_per_page = '1';
 
$view->block = TRUE;
 
$view->block_title = '123';
 
$view->block_header = '';
 
$view->block_header_format = '1';
 
$view->block_footer = '';
 
$view->block_footer_format = '1';
 
$view->block_empty = '';
 
$view->block_empty_format = '1';
 
$view->block_type = 'dynamic_teaser';
 
$view->nodes_per_block = '1';
 
$view->block_more = TRUE;
 
$view->block_use_page_header = FALSE;
 
$view->block_use_page_footer = FALSE;
 
$view->block_use_page_empty = FALSE;
 
$view->sort = array (
    array (
     
'tablename' => 'node',
     
'field' => 'created',
     
'sortorder' => 'DESC',
     
'options' => 'normal',
    ),
  );
 
$view->argument = array (
  );
 
$view->field = array (
    array (
     
'tablename' => 'node_data_field_issue_description',
     
'field' => 'field_issue_description_value',
     
'label' => '',
     
'handler' => 'content_views_field_handler_ungroup',
     
'options' => 'default',
    ),
    array (
     
'tablename' => 'node',
     
'field' => 'title',
     
'label' => '',
     
'handler' => 'views_handler_field_nodelink',
     
'options' => 'link',
    ),
    array (
     
'tablename' => 'node',
     
'field' => 'edit',
     
'label' => '',
     
'handler' => 'views_handler_node_edit_destination',
    ),
    array (
     
'tablename' => 'node',
     
'field' => 'created',
     
'label' => '',
     
'handler' => 'views_handler_field_date_small',
    ),
    array (
     
'tablename' => 'node_data_field_issue_status',
     
'field' => 'field_issue_status_value',
     
'label' => '',
     
'handler' => 'content_views_field_handler_ungroup',
     
'options' => 'default',
    ),
    array (
     
'tablename' => 'node_data_field_issue_category',
     
'field' => 'field_issue_category_value',
     
'label' => '',
     
'handler' => 'content_views_field_handler_ungroup',
     
'options' => 'default',
    ),
    array (
     
'tablename' => 'node_data_field_issue_page_referral',
     
'field' => 'field_issue_page_referral_value',
     
'label' => '',
     
'handler' => 'content_views_field_handler_ungroup',
     
'options' => 'default',
    ),
    array (
     
'tablename' => 'node_data_field_issue_error_msg',
     
'field' => 'field_issue_error_msg_value',
     
'label' => '',
     
'handler' => 'content_views_field_handler_ungroup',
     
'options' => 'default',
    ),
  );
 
$view->filter = array (
    array (
     
'tablename' => 'node',
     
'field' => 'type',
     
'operator' => 'OR',
     
'options' => '',
     
'value' => array (
 
0 => 'issue',
),
    ),
  );
 
$view->exposed_filter = array (
  );
 
$view->requires = array(node, node_data_field_issue_description, node_data_field_issue_status, node_data_field_issue_category, node_data_field_issue_page_referral, node_data_field_issue_error_msg);
 
$views[$view->name] = $view;
?>

#5

bittindm - September 6, 2007 - 00:31

Just noticed something. It seems as if the wrong function is being called to display the block. From what I can tell, it's using the block hook from dynamic views as intended but seems to be going with views_view_block() function to display it even though I can trace it to where dynamic_views_view_block() is being called in dynamic views module.

Would that make any sense? If I change the pager value in the views module on line 442 to true instead false, the old style pager shows for all blocks not the dynamic views version. Obviously this isn't something I would want to leave in there. Just trying to figure out what's going wrong.

#6

bittindm - September 7, 2007 - 00:55

Another observation I've made is that for some reason when another "regular" pager is present on the page with the dynamic block, the block pager shows up. Then when you click, it changes the record being displayed but the pager disappears.

Not sure what's going on with that but thought it could be an obscure bug or something that I need to do to make the pager persist. Let me know if anything comes to mind.

Thanks.

 
 

Drupal is a registered trademark of Dries Buytaert.