$kirby->collection()
Returns a specific user-defined collection by name. All relevant dependencies are automatically injected
$kirby->collection(string $name, array $options = [ ]): Kirby\Toolkit\Collection|null
Parameters
Name | Type | Default |
---|---|---|
$namerequired | string |
no default value |
$options | array |
[ ]
|
Return types
Kirby\Toolkit\Collection
ornull
This method modifies the existing $app
object it is applied to and returns it again.
Parent class
Examples
Call a predefined collection by key:
$articles = $kirby->collection('blog');
dump($articles);
Pass additional options
return function (string $category) {
return page('blog')->children()->filterBy('category', $category);
}
$articles = $kirby->collection('blog-category', ['category' => 'food']);