Reference

Guide

$pages->add()

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

$pages->add(mixed $object): Kirby\Cms\Pages

Parameters

Name Type Default Description
$object mixed

Return type

Kirby\Cms\Pages

Examples

Add single page by ID

$collection = page('exhibitions')->children()->listed();
$collection->add('somepage');

Add single page by $page object

$collection = page('exhibitions')->children()->listed();
$page       = Page::create([…]);
$collection->add($page');

Add second pages collection

$collection = page('exhibitions')->children()->listed();
$collection->add(page('news')->children()->listed());

Source code

kirby/src/Cms/Pages.php#L45