paginate()
Makes an array of objects by grouping the array values by page. Similar to indexPages()
but includes the items
property in each object.
This function is valid in
v2.24.0 to v2.24.3.
This function has been downloaded 28 times.
Parameters
{Array}
items
An array of items that should be chunked and the corresponding items for each page shown will be available in the returned array.
{number=}
opt_pageNumber
Optional, Default:1
The number of the page to be selected. 0
will be coerced to 1
. A negative number will be counted from the last page.
{number=}
opt_perPage
Optional, Default:10
The maximum number of items to place in each page object.
{number=}
opt_length
Optional, Default:5
The maximum number of page objects to return. The default value comes from indexPages()
.
Returns
{Array}
Array of objects representing pages. Each object will contain number
(the page number), isSelected
(a boolean indicating if the page is pageNumber
), isBoundary
(a boolean indicating if number
is pageNumber
or pageCount
), and items
(an array of the corresponding values from the items
passed in).
Required Functions
This function directly requires the following functions which are included automatically:
-
indexPages()
Makes an array of objects representing the pagination details based on the current page number, the number of pages and the maximum number of pages to show.
-
pacman()
Confines a number to a specified range by looping number that are too large back to the beginning of the range and numbers that are too small back to the end of the range (just like in Pacman).
-
slice()
Slice does not modify the original array, but instead returns a shallow copy of elements from the original array.