Skip to content

Kirby 4.4.1

$page->copy()

Copies the page to a new parent

$page->copy(array $options = [ ]): Kirby\Cms\Page

Parameters

Name Type Default
$options array [ ]

Return type

Kirby\Cms\Page

This method does not modify the existing $page object but returns a new object with the changes applied. Learn more →

Exceptions

Type Description
Kirby\Exception\DuplicateException If the page already exists

Parent class

Kirby\Cms\Page

The $options parameter

Name Type
slug string
isDraft bool
num int
children bool
files bool

Example

$copy = $page->copy(
    [
        'slug'     => $page->slug() . '-' . time(),
        'parent'   => page('blog'),
        'children' => true, // copy children
        'files'    => false, // don't copy files
    ]
);

dump($copy);

Passing no parent or passing null as value for parent will copy the page as child of $site.