This hook shows how you can get old and new pages values in a hook. This is useful when you need to compare/track changes in properties/fields.
Adapt to suit your needs.
\ProcessWire\wire()->addHookAfter('Pages::saveReady(template=my-template)', function($event) {
$page = $event->arguments(0);
if ($page->created !== 0) {
$clone = clone($page);
wire('pages')->uncache($clone);
$oldPage = wire('pages')->get($clone->id);
// Now you have $oldPage and $page to work with
}
});
Tim Bennett is a web designer and developer. He has a First Class Honours degree in Computing from
Leeds Metropolitan University and currently runs his own one-man web design company, Texelate.