PaginatedList
class PaginatedList extends ListDecorator (View source)
A decorator that wraps around a data list in order to provide pagination.
Methods
Constructs a new paginated list instance around a list.
Returns the GET var that is used to set the page start. This defaults to "start".
Sets the GET var used to set the page start.
Returns the number of items displayed per page. This defaults to 10.
Set the number of items displayed per page. Set to zero to disable paging.
Sets the current page.
Returns the offset of the item the current page starts at.
Sets the offset of the item that current page starts at. This should be a multiple of the page length.
Returns the total number of items in the unpaginated list.
Sets the total number of items in the list. This is useful when doing custom pagination.
Sets the page length, page start and total items from a query object's limit, offset and unlimited count. The query MUST have a limit clause.
Returns whether or not the underlying list is limited to the current pagination range when iterating.
No description
No description
No description
Returns a set of links to all the pages in the list. This is useful for basic pagination.
Returns a summarised pagination which limits the number of pages shown around the current page for visually balanced.
No description
No description
No description
No description
No description
No description
No description
Returns the number of the first item being displayed on the current page. This is useful for things like "displaying 10-20".
Returns the number of the last item being displayed on this page.
Returns a link to the first page.
Returns a link to the last page.
Returns a link to the next page, if there is another page after the current one.
Returns a link to the previous page, if the first page is not currently active.
Returns the total number of items in the list
Get the request object for this list
Details
__construct(SS_List $list, array|ArrayAccess $request = [])
Constructs a new paginated list instance around a list.
string
getPaginationGetVar()
Returns the GET var that is used to set the page start. This defaults to "start".
If there is more than one paginated list on a page, it is necessary to set a different get var for each using {@link setPaginationGetVar()}.
$this
setPaginationGetVar(string $var)
Sets the GET var used to set the page start.
int
getPageLength()
Returns the number of items displayed per page. This defaults to 10.
$this
setPageLength(int $length)
Set the number of items displayed per page. Set to zero to disable paging.
$this
setCurrentPage(int $page)
Sets the current page.
int
getPageStart()
Returns the offset of the item the current page starts at.
$this
setPageStart(int $start)
Sets the offset of the item that current page starts at. This should be a multiple of the page length.
int
getTotalItems()
Returns the total number of items in the unpaginated list.
$this
setTotalItems(int $items)
Sets the total number of items in the list. This is useful when doing custom pagination.
$this
setPaginationFromQuery(SQLSelect $query)
Sets the page length, page start and total items from a query object's limit, offset and unlimited count. The query MUST have a limit clause.
bool
getLimitItems()
Returns whether or not the underlying list is limited to the current pagination range when iterating.
By default the limit method will be called on the underlying list to extract the subset for the current page. In some situations, if the list is custom generated and already paginated you don't want to additionally limit the list. You can use {@link setLimitItems} to control this.
$this
setLimitItems(bool $limit)
Traversable
getIterator()
array
toArray()
SS_List
Pages(int $max = null)
Returns a set of links to all the pages in the list. This is useful for basic pagination.
By default it returns links to every page, but if you pass the $max parameter the number of pages will be limited to that number, centered around the current page.
SS_List
PaginationSummary(int $context = 4)
Returns a summarised pagination which limits the number of pages shown around the current page for visually balanced.
Example: 25 pages total, currently on page 6, context of 4 pages [prev] [1] ... [4] [5] [[6]] [7] [8] ... [25] [next]
Example template usage:
<% if MyPages.MoreThanOnePage %>
<% if MyPages.NotFirstPage %>
Prev
<% end_if %>
<% loop MyPages.PaginationSummary(4) %>
<% if CurrentBool %>
$PageNum
<% else %>
<% if Link %>
$PageNum
<% else %>
...
<% end_if %>
<% end_if %>
<% end_loop %>
<% if MyPages.NotLastPage %>
Next
<% end_if %>
<% end_if %>
int
CurrentPage()
int
TotalPages()
bool
MoreThanOnePage()
bool
FirstPage()
bool
NotFirstPage()
bool
LastPage()
bool
NotLastPage()
int
FirstItem()
Returns the number of the first item being displayed on the current page. This is useful for things like "displaying 10-20".
int
LastItem()
Returns the number of the last item being displayed on this page.
string
FirstLink()
Returns a link to the first page.
string
LastLink()
Returns a link to the last page.
string
NextLink()
Returns a link to the next page, if there is another page after the current one.
string
PrevLink()
Returns a link to the previous page, if the first page is not currently active.
TotalItems()
Returns the total number of items in the list
setRequest(HTTPRequest|ArrayAccess $request)
Set the request object for this list
getRequest()
Get the request object for this list