The question is similar to this one :

Views programmatically limit results

But i still cannot limit number of items in my view. The ways i already tried :

$args = array();
$view = views_get_view('news_details');
$view->display_handler->set_option('items_per_page', 3);
print $view->preview('default', $args);

$view = views_get_view('news_details');

$view = views_get_view('news_details');
$view->is_cacheable = FALSE;
$view->display['default']->handler->options['items_per_page'] = 3;
$view->display['default']->handler->options['title'] = $title;
$view->display['default']->handler->options['display_options']['use_pager'] = FALSE;

Whatever i am doing :

  • $view->result always returns 1 item
  • $view->preview() always returns all items

According to the answer above it seems like i need to apply this method to pager, not view, in this case how do i get access to this pager, could somebody provide working example of how to correctly limit items in view?

Got it :

I had "Display Items" set to "Display All" in pager settings of my View. It, according to Views, does not allow to filter view rows.

| improve this question | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.