Skip to main content
added 2 characters in body
Source Link
Scott Joudry
  • 4.2k
  • 3
  • 30
  • 47

The views hook that you would want to use is hook_views_pre_buildhook_views_pre_build which is called before the query is buildbuilt. Now Thisthis 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 callthat's called before the view query is buildbuilt that way the pager and everything else will reflect the change.

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

Hope this helps.

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.

The views hook that you would want to use is hook_views_pre_build which is called before the query is built. 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 that's called before the view query is built that way the pager and everything else will reflect the change.

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

Hope this helps.

edited body
Source Link
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 outour 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.

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 out 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.

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.

Source Link
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 out 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.