$blocks->findBy()
Find a single element by an attribute and its value
$blocks->findBy(string $attribute, $value): Kirby\Cms\Block|null
Parameters
| Name | Type | Default |
|---|---|---|
| $attributerequired | string |
no default value |
| $valuerequired | mixed |
no default value |
Return types
Kirby\Cms\Blockornull
This method modifies the existing $blocks object it is applied to and returns it again.
Parent class
Kirby\Cms\Blocks
inherited from Kirby\Cms\Collection
Examples
Find blocks by attribute, e.g. type:
$textBlock = $page->text()->toBlocks()->findBy('type', 'image');
Returns the first block of type image if it exists.