$pages->filterBy()

Filters the collection by any field and value and with a set of filtering operators.

Example

// fetch children with a field 'draft', which has the value 'yes'
$items = $page->children()->filterBy('draft', 'yes');

// fetch children with a date in the past
$items = $page->children()->filterBy('date', '<', time());

// fetch children with a date in the future
$items = $page->children()->filterBy('date', '>', time());

// fetch any page with a project template
$items = $site->index()->filterBy('template', 'project');

Available filter methods

Method Function
== all values, which match exactly
!= all values, which don't match
*= all values, which contain the given string
> all values, which are greater than the given value
>= all values, which are greater or equal the given value
< all values, which are smaller than the given value
<= all values, which are smaller or equal the given value