$blocks->hasType()
Checks if a given block type exists in the collection
$blocks->hasType(string $type): bool
Parameters
Name | Type | Default |
---|---|---|
$typerequired | string |
no default value |
Return type
bool
Parent class
Examples
Useful if you want to include scripts etc. depending on block types.
$blocks = $page->blocks()->toBlocks();
if ($blocks->hasType('code') === true) {
// include some scripts
}