dimaseo Dimaseo

Как приделать пейджер к любому списку

🔎 Текучка
2 июн 2016
// $list is the list of items you are paging through
$list = array ('Cat','Dog','Mouse','Horse','Pony','Winged mongoose');
$per_page = 2;
 
// Initialise the pager
$current_page = pager_default_initialize(count($list), $per_page);
 
// Split your list into page sized chunks
$chunks = array_chunk($list,$per_page, TRUE);
 
// Show the pager
print theme('pager', array('quantity',count($list)));
 
// Show the appropriate items from the list
print theme('item_list', array(
   'items' => $chunks[$current_page],
));