I have made a view with pager set to 'yes' and items per page to '15'.
Here is a partial paste of an export of my view to show where this information is stored

$handler = $view->new_display('default', 'Defaults', 'default');
---snip---
$handler->override_option('items_per_page', 15);
$handler->override_option('use_pager', '1');

However if I load the view up with <?php $view = views_get_view('view-name'); ?> and execute I only get 10 items per page. If I dsm($view->pager) I see this:

#pager (Array, 5 elements)

    * use_pager (Boolean) FALSE
    * items_per_page (Integer) 10
    * element (Integer) 0
    * offset (Integer) 0
    * current_page (Integer) 0

So it's defaulting it to '10' even though both displays in the view settings are configured to '15'.

I don't want to programatically set it to '15' - I just want it to pick up the settings from the UI, how do I do that?

Comments

dawehner’s picture

you could use

  function set_items_per_page($items_per_page) {
    $this->pager['items_per_page'] = $items_per_page;
    if (empty($items_per_page)) {
      $this->pager['use_pager'] = FALSE;
    }
  }
danielb’s picture

See, that won't work because I will need to supply my own value for $items_per_page to use that - it is a number I do not know, and it's not available in the $view object.

cchan’s picture

subscribing.

cchan’s picture

Fixed. The problem was solved by calling $view->preview() before $view->render(). Thanks for your help.

cchan’s picture

Status: Active » Closed (fixed)