$pages->when()
The when method only executes the given Closure when the first parameter is true. If the first parameter is false, the Closure will not be executed.
Parameters
Name | Type | Default |
---|---|---|
$condition * | mixed |
– |
$callback * | Closure |
– |
$fallback | Closure |
null |
Return type
mixed
Parent class
Kirby\Cms\Pages
inherited from Kirby\Toolkit\Collection
Examples
Apply the filter method only if the first parameter evaluates to true
:
With a fallback if the first parameter does not evaluate to true
: