PageCollection
extends FlexPageCollection
in package
implements
PageCollectionInterface
uses
FlexGravTrait, FlexCollectionTrait
Class GravPageCollection
Tags
Table of Contents
Interfaces
- PageCollectionInterface
- Interface PageCollectionInterface
Properties
- $_params : array<string|int, mixed>|null
Methods
- addPage() : $this
- Add a single page to a collection
- adjacentSibling() : PageInterface|false
- Returns the adjacent sibling based on a direction.
- all() : $this
- Mimicks Pages class.
- append() : static
- Append new elements to the list.
- batch() : array<string|int, static>
- Split collection into array of smaller collections.
- currentPosition() : int|null
- Returns the item in the current position.
- dateRange() : static
- Returns the items between a set of date ranges of either the page date field (default) or an arbitrary datetime page field where start date and end date are optional Dates must be passed in as text that strtotime() can process http://php.net/manual/en/function.strtotime.php
- filterBy() : static
- Filter pages by given filters.
- getCachedMethods() : array<string|int, mixed>
- getIndex() : PageIndex
- getLevelListing() : array<string|int, mixed>
- getNextOrder() : string
- getParams() : array<string|int, mixed>
- Get the collection params
- getRoot() : PageInterface
- intersect() : static
- Intersect another collection with the current collection
- isFirst() : bool
- Check to see if this item is the first in the collection.
- isLast() : bool
- Check to see if this item is the last in the collection.
- merge() : static
- Merge another collection with the current collection
- modular() : static
- Alias of modules()
- modules() : static
- Creates new collection with only modules
- nextSibling() : PageInterface|false
- Gets the next sibling based on current position.
- nonModular() : static
- Alias of pages()
- nonPublished() : static
- Creates new collection with only non-published pages
- nonRoutable() : static
- Creates new collection with only non-routable pages
- nonVisible() : static
- Creates new collection with only non-visible pages
- nth() : PageInterface|bool
- Return nth item.
- ofOneOfTheseAccessLevels() : static
- Creates new collection with only pages of one of the specified access levels
- ofOneOfTheseTypes() : static
- Creates new collection with only pages of one of the specified types
- ofType() : static
- Creates new collection with only pages of the specified type
- order() : static
- Reorder collection.
- pages() : static
- Creates new collection with only pages
- params() : array<string|int, mixed>
- Get the collection params
- prev() : PageInterface|false
- Return previous item.
- prevSibling() : PageInterface|false
- Gets the previous sibling based on current position.
- published() : static
- Creates new collection with only published pages
- random() : static
- Pick one or more random entries.
- routable() : static
- Creates new collection with only routable pages
- setCurrent() : void
- Set current page.
- setParams() : $this
- Set parameters to the Collection
- toExtendedArray() : array<string|int, mixed>
- Get the extended version of this Collection with each page keyed by route
- triggerEvent() : $this
- visible() : static
- Creates new collection with only visible pages
- withModules() : static
- withOrdered() : static
- withPages() : static
- withPublished() : static
- withRoutable() : static
- withTranslated() : PageIndex
- withTranslation() : static
- withVisible() : static
- buildSort() : array<string|int, mixed>
- getActiveUser() : UserInterface|null
- getAuthorizeScope() : string
- getContainer() : Grav
- getFlexContainer() : Flex
- isAdminSite() : bool
Properties
$_params
protected
array<string|int, mixed>|null
$_params
Methods
addPage()
Add a single page to a collection
public
addPage(PageInterface $page) : $this
Parameters
- $page : PageInterface
Return values
$thisadjacentSibling()
Returns the adjacent sibling based on a direction.
public
adjacentSibling(string $path[, int $direction = 1 ]) : PageInterface|false
Parameters
- $path : string
- $direction : int = 1
-
either -1 or +1
Tags
Return values
PageInterface|false —The sibling item.
all()
Mimicks Pages class.
public
all() : $this
Not needed anymore in Flex Pages (does nothing).
Return values
$thisappend()
Append new elements to the list.
public
append(array<string|int, mixed> $items) : static
Parameters
- $items : array<string|int, mixed>
-
Items to be appended. Existing keys will be overridden with the new values.
Tags
Return values
staticbatch()
Split collection into array of smaller collections.
public
batch(int $size) : array<string|int, static>
Parameters
- $size : int
Tags
Return values
array<string|int, static>currentPosition()
Returns the item in the current position.
public
currentPosition(string $path) : int|null
Parameters
- $path : string
-
the path the item
Return values
int|null —The index of the current page, null if not found.
dateRange()
Returns the items between a set of date ranges of either the page date field (default) or an arbitrary datetime page field where start date and end date are optional Dates must be passed in as text that strtotime() can process http://php.net/manual/en/function.strtotime.php
public
dateRange([string|null $startDate = null ][, string|null $endDate = null ][, string|null $field = null ]) : static
Parameters
- $startDate : string|null = null
- $endDate : string|null = null
- $field : string|null = null
Tags
Return values
staticfilterBy()
Filter pages by given filters.
public
filterBy(array<string|int, mixed> $filters[, bool $recursive = false ]) : static
- search: string
- page_type: string|string[]
- modular: bool
- visible: bool
- routable: bool
- published: bool
- page: bool
- translated: bool
Parameters
- $filters : array<string|int, mixed>
- $recursive : bool = false
Tags
Return values
staticgetCachedMethods()
public
static getCachedMethods() : array<string|int, mixed>
Return values
array<string|int, mixed>getIndex()
public
getIndex() : PageIndex
Return values
PageIndexgetLevelListing()
public
getLevelListing(array<string|int, mixed> $options) : array<string|int, mixed>
Parameters
- $options : array<string|int, mixed>
Return values
array<string|int, mixed>getNextOrder()
public
getNextOrder() : string
Return values
stringgetParams()
Get the collection params
public
getParams() : array<string|int, mixed>
Return values
array<string|int, mixed>getRoot()
public
getRoot() : PageInterface
Return values
PageInterfaceintersect()
Intersect another collection with the current collection
public
intersect(PageCollectionInterface $collection) : static
Parameters
- $collection : PageCollectionInterface
Tags
Return values
staticisFirst()
Check to see if this item is the first in the collection.
public
isFirst(string $path) : bool
Parameters
- $path : string
Return values
bool —True if item is first.
isLast()
Check to see if this item is the last in the collection.
public
isLast(string $path) : bool
Parameters
- $path : string
Return values
bool —True if item is last.
merge()
Merge another collection with the current collection
public
merge(PageCollectionInterface $collection) : static
Parameters
- $collection : PageCollectionInterface
Tags
Return values
staticmodular()
Alias of modules()
public
modular() : static
Tags
Return values
staticmodules()
Creates new collection with only modules
public
modules() : static
Tags
Return values
static —The collection with only modules
nextSibling()
Gets the next sibling based on current position.
public
nextSibling(string $path) : PageInterface|false
Parameters
- $path : string
Tags
Return values
PageInterface|false —The next item.
nonModular()
Alias of pages()
public
nonModular() : static
Tags
Return values
staticnonPublished()
Creates new collection with only non-published pages
public
nonPublished() : static
Tags
Return values
static —The collection with only non-published pages
nonRoutable()
Creates new collection with only non-routable pages
public
nonRoutable() : static
Tags
Return values
static —The collection with only non-routable pages
nonVisible()
Creates new collection with only non-visible pages
public
nonVisible() : static
Tags
Return values
static —The collection with only non-visible pages
nth()
Return nth item.
public
nth(int $key) : PageInterface|bool
Parameters
- $key : int
Tags
Return values
PageInterface|boolofOneOfTheseAccessLevels()
Creates new collection with only pages of one of the specified access levels
public
ofOneOfTheseAccessLevels(array<string|int, mixed> $accessLevels) : static
Parameters
- $accessLevels : array<string|int, mixed>
Tags
Return values
static —The collection
ofOneOfTheseTypes()
Creates new collection with only pages of one of the specified types
public
ofOneOfTheseTypes(array<string|int, string> $types) : static
Parameters
- $types : array<string|int, string>
Tags
Return values
static —The collection
ofType()
Creates new collection with only pages of the specified type
public
ofType(string $type) : static
Parameters
- $type : string
Tags
Return values
static —The collection
order()
Reorder collection.
public
order(string $by[, string $dir = 'asc' ][, array<string|int, mixed>|null $manual = null ][, int|null $sort_flags = null ]) : static
Parameters
- $by : string
- $dir : string = 'asc'
- $manual : array<string|int, mixed>|null = null
- $sort_flags : int|null = null
Tags
Return values
staticpages()
Creates new collection with only pages
public
pages() : static
Tags
Return values
static —The collection with only pages
params()
Get the collection params
public
params() : array<string|int, mixed>
Return values
array<string|int, mixed>prev()
Return previous item.
public
prev() : PageInterface|false
Tags
Return values
PageInterface|falseprevSibling()
Gets the previous sibling based on current position.
public
prevSibling(string $path) : PageInterface|false
Parameters
- $path : string
Tags
Return values
PageInterface|false —The previous item.
published()
Creates new collection with only published pages
public
published() : static
Tags
Return values
static —The collection with only published pages
random()
Pick one or more random entries.
public
random([int $num = 1 ]) : static
Parameters
- $num : int = 1
-
Specifies how many entries should be picked.
Tags
Return values
staticroutable()
Creates new collection with only routable pages
public
routable() : static
Tags
Return values
static —The collection with only routable pages
setCurrent()
Set current page.
public
setCurrent(string $path) : void
Parameters
- $path : string
setParams()
Set parameters to the Collection
public
setParams(array<string|int, mixed> $params) : $this
Parameters
- $params : array<string|int, mixed>
Return values
$thistoExtendedArray()
Get the extended version of this Collection with each page keyed by route
public
toExtendedArray() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>triggerEvent()
public
triggerEvent(string $name[, object|null $event = null ]) : $this
Parameters
- $name : string
- $event : object|null = null
Return values
$thisvisible()
Creates new collection with only visible pages
public
visible() : static
Tags
Return values
static —The collection with only visible pages
withModules()
public
withModules([bool $bool = true ]) : static
Parameters
- $bool : bool = true
Tags
Return values
staticwithOrdered()
public
withOrdered([bool $bool = true ]) : static
Parameters
- $bool : bool = true
Tags
Return values
staticwithPages()
public
withPages([bool $bool = true ]) : static
Parameters
- $bool : bool = true
Tags
Return values
staticwithPublished()
public
withPublished([bool $bool = true ]) : static
Parameters
- $bool : bool = true
Tags
Return values
staticwithRoutable()
public
withRoutable([bool $bool = true ]) : static
Parameters
- $bool : bool = true
Tags
Return values
staticwithTranslated()
public
withTranslated([string|null $languageCode = null ][, bool|null $fallback = null ]) : PageIndex
Parameters
- $languageCode : string|null = null
- $fallback : bool|null = null
Return values
PageIndexwithTranslation()
public
withTranslation([bool $bool = true ][, string|null $languageCode = null ][, bool|null $fallback = null ]) : static
Parameters
- $bool : bool = true
- $languageCode : string|null = null
- $fallback : bool|null = null
Tags
Return values
staticwithVisible()
public
withVisible([bool $bool = true ]) : static
Parameters
- $bool : bool = true
Tags
Return values
staticbuildSort()
protected
buildSort([string $order_by = 'default' ][, string $order_dir = 'asc' ][, array<string|int, mixed>|null $manual = null ][, int|null $sort_flags = null ]) : array<string|int, mixed>
Parameters
- $order_by : string = 'default'
- $order_dir : string = 'asc'
- $manual : array<string|int, mixed>|null = null
- $sort_flags : int|null = null
Return values
array<string|int, mixed>getActiveUser()
protected
getActiveUser() : UserInterface|null
Return values
UserInterface|nullgetAuthorizeScope()
protected
getAuthorizeScope() : string
Return values
stringgetContainer()
protected
getContainer() : Grav
Return values
GravgetFlexContainer()
protected
getFlexContainer() : Flex
Return values
FlexisAdminSite()
protected
isAdminSite() : bool