Automad
 All Classes Functions Variables Pages
Automad\Core\Pagelist Class Reference

Public Member Functions

 __construct ($collection, $Context)
 
 config ($options=array())
 
 getTags ()
 
 getPages ($offset=0, $limit=NULL)
 

Private Member Functions

 getRelevant ()
 

Private Attributes

 $collection
 
 $Context
 
 $defaults
 
 $type
 
 $parent
 
 $template
 
 $sortItem
 
 $sortOrder
 
 $filter = false
 
 $search = false
 

Detailed Description

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

The main properties of a Pagelist object are:

  • A selection of Page objects (filtered)
  • An array of tags (not filtered, but only from pages matching $type, $template & $search)

The criterias for the selection of Page objects are:

  • $type (false (all pages), "children", "related", "siblings" or "breadcrumbs")
  • $parent (is only used, when $type is "children" - default is the current page)
  • $template (if passed, only pages with that template get included)
  • the 'search' element from the query string (if existant, the selection gets filtered by these keywords)

Since the selection of pages will also be filtered by the keywords passed as the 'search' element in the query string, this object can easily be used on a search results page. Basically a search results page can just be a normal page with a Pagelist object, where a search box passes the 'search' value to.

The visibility and order of the pages get influenced by the following elements within a query string:

  • filter
  • search
  • sortItem
  • sortOrder
Author
Marc Anton Dahmen hello.nosp@m.@mar.nosp@m.cdahm.nosp@m.en.d.nosp@m.e
License
MIT license - http://automad.org/license

Definition at line 72 of file pagelist.php.

Constructor & Destructor Documentation

Automad\Core\Pagelist::__construct (   $collection,
  $Context 
)

Initialize the Pagelist.

Parameters
array$collection
object$Context

Definition at line 160 of file pagelist.php.

References Automad\Core\Automad\$collection, and Automad\Core\Automad\$Context.

Member Function Documentation

Automad\Core\Pagelist::config (   $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.

Parameters
array$options
Returns
Updated $options

Definition at line 177 of file pagelist.php.

References Automad\Core\Debug\log(), and Automad\Core\Parse\queryArray().

Automad\Core\Pagelist::getPages (   $offset = 0,
  $limit = NULL 
)

The final set of Page objects - filtered and sorted.

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
integer$offset
integer$limit
Returns
The filtered and sorted array of Page objects

Definition at line 288 of file pagelist.php.

References Automad\Core\Debug\log().

Automad\Core\Pagelist::getRelevant ( )
private

Collect all pages matching $type (& optional $parent), $template & $search (optional). (Without filtering by tag and sorting!) 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.

Also note that $this->offset & $this->limit reduces the set of all relevant pages and tags of the pagelist object while using the $offset or $limit parameters of $this->getPages() only reduces the output and will not affect the relevant pages and the collected tags.

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

Definition at line 223 of file pagelist.php.

References Automad\Core\Context\get().

Automad\Core\Pagelist::getTags ( )

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

Returns
A sorted array with the relevant tags.

Definition at line 260 of file pagelist.php.

Member Data Documentation

Automad\Core\Pagelist::$collection
private

The collection of all existing pages.

Definition at line 79 of file pagelist.php.

Automad\Core\Pagelist::$Context
private

The context.

Definition at line 86 of file pagelist.php.

Automad\Core\Pagelist::$defaults
private
Initial value:
= array(
'type' => false,
'parent' => AM_REQUEST,
'template' => false,
'sortItem' => false,
'sortOrder' => AM_LIST_DEFAULT_SORT_ORDER,
'offset' => 0,
'limit' => NULL
)

The default set of options.

Definition at line 93 of file pagelist.php.

Automad\Core\Pagelist::$filter = false
private

The current filter (from possible query string).

Definition at line 143 of file pagelist.php.

Automad\Core\Pagelist::$parent
private

In case $type is set to "children", the $parent URL can be used as well to change the parent from the current page to any page.

Definition at line 115 of file pagelist.php.

Automad\Core\Pagelist::$search = false
private

The search string to filter pages (from possible query string).

Definition at line 150 of file pagelist.php.

Automad\Core\Pagelist::$sortItem
private

The current sortItem (from possible query string).

Definition at line 129 of file pagelist.php.

Automad\Core\Pagelist::$sortOrder
private

The current sortOrder (from possible query string).

Definition at line 136 of file pagelist.php.

Automad\Core\Pagelist::$template
private

The template to filter by the pagelist.

Definition at line 122 of file pagelist.php.

Automad\Core\Pagelist::$type
private

The pagelist's type (all pages, children pages or related pages)

Definition at line 108 of file pagelist.php.


The documentation for this class was generated from the following file: