Panel page update ( Hook )

You can do the same thing a bit more elegant like so:

kirby()->hook('panel.page.update', function($page) {
  if($page->parent()->parution()->isNotEmpty()) {
    $p  = $page->parution()->toString();
    $pp = $page->parent()->parution()->toString();
    
    if($p !== $pp) {
      try {
        $page->update(array(
          'parution' => $pp
        ));
      } catch (Exception $e) {
        echo $e->getMessage();
      }
    }
  }
});
1 Like