Paginate an array

Permalink
Hey developers!

I need a pagination tool on a array. The array is data from an external datalist. So no database queries available.

Any suggestions?

Best,

Corretje

DeWebmakers
 
ScottC replied on at Permalink Reply
ScottC
You'd still want to use the pagination helper but you would want to mesh it with array_slice for paging, or a limit sql statement merely to serve the chunk of stuff your pagination helper is providing the ui for.
DeWebmakers replied on at Permalink Reply
DeWebmakers
Exactly, but how to do this?
bobrocke replied on at Permalink Reply
bobrocke
Did you ever get this figured out? How? I need to do the same thing.

Bob
DeWebmakers replied on at Permalink Reply
DeWebmakers
Hi,

Yes! I did figure it out.

You need to use the ItemList library. Example:
Loader::library('item_list');
$il = new ItemList();
$il->setItemsPerPage(10); //10 items per page
$il->setItems($my_array); // array with all items
$results = $il->getPage(); // the results
$pagination = $il->getPagination(); // pagination object


Best,

Corretje