Skip to content

Kirby 4.4.1

$blocks->add()

Adds a single object or an entire second collection to the current collection

$blocks->add(mixed $object)

Parameters

Name Type Default
$object * mixed

Parent class

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

Example

$blocks = new \Kirby\Cms\Blocks();

$newBlock = new Kirby\Cms\Block([
    'content' => [
        'text' => '<p>Hug them if you like. They might not appreciate it though.</p><p>Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vestibulum id ligula porta felis euismod semper. Donec sed odio dui. Etiam porta sem malesuada magna mollis euismod.</p>',
    ],
    'type' => 'text',
]);

$blocks = $blocks->add($newBlock);

See also Add blocks to a blocks field programmatically.