3

views_get_view_result() returns the results of the first pagination page (views pager). Is there a way to retrieve a specific page pagination results?

I have tried views_get_view_result('MYVIEW', 'MYDISPLAY', array('page' => 3)); but no juice.

If this function specifically does not do this trick, is there any that does?

1 Answer 1

3

I think I have it figured out:

$myview = views_get_view('MYVIEW');
$myview->set_display('MYDISPLAY');
$myview->set_current_page(3); // Get the pagination page 3 
$myview->pre_execute();
$myview->execute();

dpm($myview->result); // You need Devel module for using dpm()
2
  • I am using Drupal 7.x and this method is not working for me. It is fetching all records. I have 5 records in total. Is there any change in version 7.x?
    – Arun
    Jan 4, 2018 at 4:56
  • Having only 5 items most likely means that you have only one result page. By default you get the first page of the results. If you have only one page than you wont be able to test a page jumping. Jan 4, 2018 at 6:41

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.