Skip to content

Kirby 3.9.8

$blocks->has()

Checks if the given object or id is in the collection

$blocks->has(string|object $key): bool

Parameters

Name Type Default
$key * string|object

Return type

bool

Parent class

Kirby\Cms\Blocks inherited from Kirby\Cms\Collection

Example

Check if a block exists

<?php
if ($page->text()->toBlocks()->has('b03f40c3-1dc5-4a89-8874-24f616f86e51')) {
    echo 'Found the block by id';
}