Reference

Guide

$page->update()

Updates the page data

$page->update(array $input = null, string $language = null, bool $validate = false): Kirby\Cms\Page

Parameters

Name Type Default Description
$input array null
$language string null
$validate bool false

Return type

Kirby\Cms\Page

Example

try {

  page('mypage')->update([
    'title'        => 'A new title',
    'text'         => 'Some text',
    'anotherfield' => 'Some more data'
  ]);

  echo 'The page has been updated';

} catch(Exception $e) {

  echo $e->getMessage();

}

Updating a field by callback

$page->update([
  'title' => function($title) {
    return str::lower($title);
  }
]);

Multi-language site

Use the optional $lang parameter to specify the language you want to update.

try {

  page('mypage')->update([
    'title'        => 'A new title',
    'text'         => 'Some text',
    'anotherfield' => 'Some more data'
  ], 'en');

  echo 'The page has been updated';

} catch(Exception $e) {

  echo $e->getMessage();

}

Source code

kirby/src/Cms/PageActions.php#L642