Skip to main content
2 of 3
edited body
ericduran
  • 3.5k
  • 18
  • 23

The views hook that you would want to use is hook_views_pre_build which is called before the query is build. Now This is assuming you have some basic module development experience and that you are familiar with the views api.

You should be able to do :

/*
 * Implementation of hook_views_pre_build().
 */
function hook_views_pre_build(&$view){
  // Make sure this is only for the specific view you want to modified
  if ($view->name == "foo_bar") {

    // Get the x-y value from where you're storing it (in your example the node object).
    $pager_count = get_count_for_this_node();

    // Lets also make sure that this is a number so we won't destroy our view.
    if (is_numeric($pager_count)) {

      // Now lets set the pager item to what ever out count is.
      $view->pager['items_per_page'] = $pager_count;
    }
  }
}

Above we're using a views hook thats call before the view query is build that way the pager and everything else will reflect the change.

Word of cautious views hooks should only be used if you understand whats going on. The above code is written for views-2.x.

Hope this helps.

ericduran
  • 3.5k
  • 18
  • 23