$pages->filterBy()
Alias for Kirby\Cms\Pages::filter()
$pages->filterBy(...$args): Kirby\Cms\Pages
Parameters
| Name | Type | Default | 
|---|---|---|
| ...$args | mixed | 
				no default value | 
Return type
This method does not modify the existing $pages object but returns a new object with the changes applied. Learn more →
Parent class
	Kirby\Cms\Pages
		inherited from Kirby\Toolkit\Collection	
Available filter methods
| Method | Function | 
|---|---|
== | 
all values that match exactly | 
!= | 
all values that don't match | 
in | 
takes an array as parameter, matches all values that are included in the array | 
not in | 
takes an array as parameter, matches all values that are not included in the array | 
> | 
all values that are greater than the given value | 
>= | 
all values that are greater or equal the given value | 
< | 
all values that are smaller than the given value | 
<= | 
all values that are smaller or equal the given value | 
*= | 
all values that contain the given string | 
!*= | 
all values that don't contain the given string | 
^= | 
all values that start with the given string | 
!^= | 
all values that don't start with the given string | 
$= | 
all values that end with the given string | 
!$= | 
all values that don't end with the given string | 
* | 
all values that match the given regular expression | 
!* | 
all values that don't match the given regular expression | 
between or ..
 | 
takes an array as parameter with two parameters; first is the min value, second is the max value | 
maxlength | 
all values that have the given maximum length | 
minlength | 
all values that have the given minimum length | 
maxwords | 
all values that have the given maximum amount of words | 
minwords | 
all values that have the given minimum amount of words | 
date == | 
all date values that exactly match the given date string | 
date != | 
all date values that don't match the given date string | 
date > | 
all date values that are later than the given date string | 
date >= | 
all date values that are later or equal the given date string | 
date < | 
all date values that are earlier than the given date string | 
date <= | 
all date values that are earlier or equal the given date string | 
date between or date ..
 | 
all date values that are between the given date strings | 
Examples
// 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()->filter(
    fn ($child) => $child->date()->toDate() < time()
);
// fetch children with a date in the future
$items = $page->children()->filter(
    fn ($child) => $child->date()->toDate() > time()
);
// fetch any page with a project template
$items = $site->index()->filterBy('template', 'project');
// fetch any page with either an article or project template
$items = $site->index()->filterBy('template', 'in', ['article', 'project']);
// fetch children that have the tag 'development'
$items = $page->children()->filterBy('tag', 'development', ',');
// fetch children that have the tag 'development' from a tags field with separator ';'
$items = $page->children()->filterBy('tag', 'development', ';');