Drupal 7 pager without db_query Or for array content

Public

Pager using array instead of db query

</> CopyGet raw version
php
  1. // Source: https://www.drupal.org/node/1966736#comment-8792051
  2.  
  3. $per_page = 10;
  4. // Initialize the pager
  5. $current_page = pager_default_initialize(count($rows), $per_page);
  6. // Split your list into page sized chunks
  7. $chunks = array_chunk($rows, $per_page, TRUE);
  8. // Show the appropriate items from the list
  9. $output = theme('table', array('header' => $header, 'rows' => $chunks[$current_page]));
  10. // Show the pager
  11. $output .= theme('pager', array('quantity',count($rows)));