Skip to content

Kirby 3.9.8

Page::create()

Creates and stores a new page

Page::create(array $props): Kirby\Cms\Page

Parameters

Name Type Default
$props * array

For the $props parameter, you pass an array with the following data, which will be used to set up the Kirby\Cms\Page object:

Name Type Description
blueprint array Sets the Blueprint object
children array Sets the published children collection
content array Sets the Content object
dirname string Sets the dirname manually, which works
more reliable in connection with the inventory
than computing the dirname afterwards
drafts array Sets the draft children collection
files array Sets the Files collection
isDraft bool Sets the draft flag
num int Sets the sorting number
parent Kirby\Cms\Page Sets the parent page object
root string Sets the absolute path to the page
slug * string Sets the required Page slug
template string Sets the intended template
translations array Create the translations collection from an array
url string Sets the Url

Return type

Kirby\Cms\Page

Parent class

Kirby\Cms\Page

Example

$page = Page::create([
  'slug'     => 'a-new-article',
  'template' => 'article',
  'content' => [
    'title'  => 'A new article',
    'author' => 'Homer Simpson'
  ]
]);