Skip to content

Kirby 3.7.5

$pages->map()

Map a function to each element

$pages->map(callable $callback): Kirby\Cms\Pages

Parameters

Name Type Default
$callback * callable

Return type

Kirby\Cms\Pages

This method modifies the existing $pages object it is applied to and returns it again.

Parent class

Kirby\Cms\Pages inherited from Kirby\Toolkit\Collection

Example

function changeDate($page)  {
  if($page->year() == '2015') {
    $page->update([
    'year' => '2016',
  ]);
  }
}
page('projects')->children()->map('changeDate');