Jump to content

Having trouble getting page changes


androbey
 Share

Recommended Posts

Hi all, 

For one page template I want to track all changes made to pages with this template (ideally including repeater fields). 

However, I can't even track changes of simple text fields and I don't know why. It's important to note that I add and change pages via the API and not in the backend. For each page change I added:

<?php

// get the page $p
$p->setTrackChanges(Wire::trackChangesValues);
$p->setTrackChanges(true);

//do changes to fields...
$p->save();

I have a autoload module which hooks after Pages::saveReady. 

<?php

/* get the page from the HookEvent

 $page->getChanges(true); returns always empty array
 $page->getChanges(); returns always empty array
 
 However on the same run checking a field explicitly ProcessWire recognizes that a field is changed: 
*/

if ($page->isChanged('sample_field')) {
  //code in here is executed..
}

Changing a field in ProcessWire backend "$page->getChanges(true)" does return an assoc array with changed fields, but the value is always null.

Clearly I must do something wrong, but what is ist?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...