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
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
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.
Exactly, but how to do this?
Did you ever get this figured out? How? I need to do the same thing.
Bob
Bob
Hi,
Yes! I did figure it out.
You need to use the ItemList library. Example:
Best,
Corretje
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