Skip to content

Kirby 5.1.1

$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

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

Parent class

Kirby\Cms\Layouts

Examples

The method makes it easy to filter blocks from layouts:

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