class Pagelist (View source)

A Pagelist object represents a set of Page objects (matching certain criterias).

Properties

private $collection The collection of all existing pages.
private $Context The context.
private $context In case $type is set to "children", the $context URL can be used as well to change the context from the current page to any page.
private $defaults The default set of options.
private $excludeCurrent Defines whether the pagelist excludes the current page or not.
private $excludeHidden Defines whether the pagelist excludes hidden pages or not.
private $filter The current filter.
private $limit Defines the maximum number of pages in the array returned by getPages().
private $match Defines a JSON string to be used as paramter for the $Selection->match() method.
private $offset Defines the offset within the array of pages returned by getPages().
private $page The current page of the pagination.
$search The search string to filter pages.
private $sort The sort options string.
private $template The template to filter by the pagelist.
private $type The pagelist's type (all pages, children pages or related pages)

Methods

__construct(array $collection, Context $Context)

Initialize the Pagelist.

array
config(array $options = array())

Set or change the configuration of the pagelist and return the current configuration as array.

array
getDefaults()

Return the default options array.

array
getPages(bool $ignoreLimit = false)

The final set of Page objects - filtered.

number
getPaginationCount()

Calculate the number of pages of the pagination.

array
getTags()

Return all tags from all pages in $relevant as array.

array
getRelevant()

Collect all pages matching $type (& optional $context), $template & $search (optional).

Details

__construct(array $collection, Context $Context)

Initialize the Pagelist.

Parameters

array $collection
Context $Context

array config(array $options = array())

Set or change the configuration of the pagelist and return the current configuration as array.

To just get the config, call the method without passing $options.

Options:

  • context: an optionally fixed URL for the context of a pagelist of type breadcrumbs or children. In case this parameter is false, within a loop the context always changes dynamically to the current page.
  • excludeCurrent: default false
  • excludeHidden: default true
  • filter: filter pages by tags
  • limit: limit the object's array of relevant pages
  • match: filter pages by matching one or more key/regex combinations passed as JSON string
  • offset: offset the within the array of all relevant pages
  • page: false (the current page in the pagination - to be used with the limit parameter)
  • search: filter pages by search string
  • sort: sorting options string, like "date desc, title asc"
  • template: include only pages matching that template
  • type: sets the type of pagelist (default is false) - valid types are false (all), "children", "related", "siblings" and "breadcrumbs"

Parameters

array $options

Return Value

array Updated $options

array getDefaults()

Return the default options array.

Return Value

array Default options

array getPages(bool $ignoreLimit = false)

The final set of Page objects - filtered.

Note that $offset & $limit only reduce the output and not the array of relevant pages! Using the getTags() method will still output all tags, even if pages with such tags are not returned due to the limit. Sorting a pagelist will also sort all pages and therefore the set of returned pages might always be different.

Parameters

bool $ignoreLimit

Return Value

array The filtered and sorted array of Page objects

number getPaginationCount()

Calculate the number of pages of the pagination.

Return Value

number The number of pages of the current pagelist.

array getTags()

Return all tags from all pages in $relevant as array.

Return Value

array A sorted array with the relevant tags.

private array getRelevant()

Collect all pages matching $type (& optional $context), $template & $search (optional).

The returned pages have to be used to get all relevant tags. It is important, that the pages are not filtered by tag here, because that would also eliminate the non-selected tags itself when filtering.

Return Value

array An array of all Page objects matching $type & $template excludng the current page.