Events::addListener question
Permalink
I can't seem to find an answer to this in info online, so I am hoping someone knows this.
My custom 'on_page_update' event listener function seems to be called before the data is written to the database, not after. I change a page attribute from A to B, press save, and expecting the event listener to get new B attribute, but it gets the old A attribute.
Is there any way to get a listener to fire AFTER the data has been updated? There is no "on_page_updated" event, but is there something equivalent? I tried "on_page_version_approved" but that does not work. Or, is there a way to see what the B data is before it is written from within the event function? It would be a very bad practice use pending data before it gets written, and I would have to ton a bunch of rollback-on-error stuff, but if that is the only way...
In short, is there any way I can trigger an event after the page is saved. This is needed to sync C5 data to an external database that needs to be integrated. There must be some way to do that.
Thanks
My custom 'on_page_update' event listener function seems to be called before the data is written to the database, not after. I change a page attribute from A to B, press save, and expecting the event listener to get new B attribute, but it gets the old A attribute.
Is there any way to get a listener to fire AFTER the data has been updated? There is no "on_page_updated" event, but is there something equivalent? I tried "on_page_version_approved" but that does not work. Or, is there a way to see what the B data is before it is written from within the event function? It would be a very bad practice use pending data before it gets written, and I would have to ton a bunch of rollback-on-error stuff, but if that is the only way...
In short, is there any way I can trigger an event after the page is saved. This is needed to sync C5 data to an external database that needs to be integrated. There must be some way to do that.
Thanks
Have you tried if the on_page_type_publish Event does what you want?
the problem is changing attributes do not trigger a publish. However, it seems like on_page_version_approve might work as attribute changes modify the version which requests approval. The only other alternative is after saving the attribute changes, go back into edit mode and click "publish", then the publish trigger works. So, currently, I have
which should take care of all possibilities... bit of a pain, but works... so far
I can trigger events, but I can't trigger the process that triggers events, like triggering a publish, which is the better solution.
thanks
Events::addListener('on_page_update', function($event) { push_on_pub($event); }); Events::addListener('on_page_type_publish', function($event) { push_on_pub($event); }); Events::addListener('on_page_version_approve', function($event) { push_on_pub($event); });
which should take care of all possibilities... bit of a pain, but works... so far
I can trigger events, but I can't trigger the process that triggers events, like triggering a publish, which is the better solution.
thanks