$page->update($data = array() [, $lang = null])

Updates the page content with all passed variables.

  • $data (array)
    The page data to be updated
  • $language (string)
    Optional, language code (only in case of a multi-language site)
  • return ($page)

Example

try {

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

  echo 'The page has been updated';

} catch(Exception $e) {

  echo $e->getMessage();

}

2.3.0 +

Updating a field by callback

$page->update(array(
  '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(array(
    'title'        => 'A new title',
    'text'         => 'Some text',
    'anotherfield' => 'Some more data'
  ), 'en');

  echo 'The page has been updated';

} catch(Exception $e) {

  echo $e->getMessage();

}