Items Per Page Get Parameter for Views


/ Published in: PHP
Save to your folder(s)

Use the following module code to add a Show parameter to your URL.


Copy this code and paste it in your HTML
  1. <?php
  2. /**
  3. * Implements hook_views_pre_execute().
  4. *
  5. * This allows us to adjust the number of rows to present, and to add the pager
  6. * count display functionality.
  7. *
  8. * @param stdClass $view The view to alter.
  9. */
  10. function YOURMODULEHERE_views_pre_execute(&$view) {
  11. $show = $_GET['show'];
  12. if( $show == 'all' ) $show = 0;
  13.  
  14. if( is_numeric($show) )
  15. {
  16. $view->pager['items_per_page'] = $show;
  17. $view->handler->options['items_per_page'] = $show;
  18. }
  19. }
  20. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.