$blocks->has()
Checks if the given object or id is in the collection
$blocks->has(string|Kirby\Cms\Block $key): bool
Parameters
Name | Type | Default |
---|---|---|
$keyrequired | string orKirby\Cms\Block |
no default value |
Return type
bool
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
Check if a block exists
<?php
if ($page->text()->toBlocks()->has('b03f40c3-1dc5-4a89-8874-24f616f86e51')) {
echo 'Found the block by id';
}