Hi folks,
A way to hook the “panel.page.keep” ?
Work in progress…
Noticed that there are no way to preview your changes in the panel, so I decided to have a go at it.
For now it´s a preview field containing an iFrame that updates a preview page on click of a button.
Now I am trying to hook that update on "panel.page.keep, so you don´t have to push the button all the time, something like this:
kirby()->hook('panel.page.keep', function($page) {
$data = $page->content()->toArray();
$data['title'] = $page->title();
$data = array_merge($data, $page->changes()->get());
if ($preview = $page->find('preview')) {
if ($data) {
$preview->update($data);
}
} else {
$temp = $page->intendedTemplate();
$content = $page->content()->toArray();
$content['title'] = $page->title();
$uri = $page->uri() .DS. "preview";
$page->create($uri, $temp, $content);
}
});