Detect changes inside hook

Hi everyone,

I’m currently trying to compare a page that has been updated via the panel with its state before the update:

kirby()->hook('', function ($page, $oldpage) {
  $dir = kirby()->roots()->index() . DS . '';
  file_put_contents($dir, $oldpage->title() . ' --> ' . $page->title());

Unfortunately the title of both objects ($page and $oldpage) represents the state after the update though I would expect the $oldpage->title() to hold the title before the update event.

Are there any settings I have to change in order to be able to use the $oldpage object?
I’m using Kirby v2.5.12

Hm, maybe you have an environment as mentioned in this issue report?

That’s right, I actually do. Looks like I’ll have to store the oldpage data in seperate hidden fields and overwrite them after I extracted the old data within the hook.
Thanks for the info :slight_smile: