I'm building a view programmatically, and this is the page info configuration i have to do:

$view->query->pager->total_items = $count;
$view->query->pager->current_page = isset( $params[ 'page' ] ) ? $params[ 'page' ] : 0;
$view->current_page =isset( $params[ 'page' ] ) ? $params[ 'page' ] : 0;

$view->query->pager->options[ 'total_pages' ] = ceil( $count / 8 );
$view->total_rows = ceil( $count / 4 );

$view->items_per_page = $view->query->pager->options[ 'items_per_page' ];

The problem is i had to add an infinite scrolling to the view so i used views infinite scroll module, but it's not likeing the way i'm making these settings.

If i say the current page is 0 then the first page is loaded twice and at the end it's not loading all the data.

Could someone point me to the right direction to adjust these settings? Or any idea on what i could do to make this work? It would be much appreciated.

  • Could you describe what your custom Views module is doing and how it is interacting with Views? For example are you altering Views using hooks? As you are using views_infinite_scroll you may want to use the hook_views_ajax_data_alter hook. api.drupal.org/api/views/views.api.php/group/views_hooks/7 Nov 23, 2013 at 14:25
  • I am altering the view using hook_pre_render( &$view ). In the hook_views_ajax_data_alter hook what should i change?
    – adevms
    Nov 23, 2013 at 14:27
  • If its working without views_infinte_scroll then you shouldn't need to use the hook_views_ajax_data_alter hook. What is it that you are doing in the hook_pre_render? Are you artificially altering the total number of results (your $count variable)? Why are you changing $views->total_rows? I'd go through your hook_pre_render and comment out one line at a time until views_infinite_scroll starts working again. Nov 23, 2013 at 14:45
  • Maybe you should take a look at this answer too drupal.stackexchange.com/questions/86007/… Nov 23, 2013 at 14:57
  • The data is from a feed so i need to alter the views total_rows attribute. I don't think the views infinite scroll worked at the beginning either. The link you gave doesen't mention the infinite scroll module.
    – adevms
    Nov 25, 2013 at 16:37


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.