Skip to content

Kirby 3.9.8

$layouts->toBlocks()

Converts layouts to blocks

$layouts->toBlocks(bool $includeHidden = false): Kirby\Cms\Blocks

Parameters

Name Type Default Description
$includeHidden bool false Sets whether to include hidden blocks

Return type

Kirby\Cms\Blocks

Parent class

Kirby\Cms\Layouts

Example

The method makes it easy to filter blocks from layouts:

$layouts = $page->layout()->toLayouts();
$blocks  = $layouts->toBlocks();
$banner  = $blocks->filter('type', 'banner')->first();