Skip to content

Kirby 5.0.4

$layouts->hasBlockType()

Checks if a given block type exists in the layouts collection

$layouts->hasBlockType(string $type): bool

Parameters

Name Type Default
$typerequired string no default value

Return type

bool

This method modifies the existing $layouts object it is applied to and returns it again.

Parent class

Kirby\Cms\Layouts

Examples

Useful if you want to include scripts etc. depending on block types in layout field.

$layouts = $page->layout()->toLayouts();

if ($layouts->hasBlockType('heading') === true) {
  // include some scripts
}