As already requested by Discord here is our small solution for a very simple and easy changelog for pages. Thanks to @texnixe for help with the function a few months ago. The hook can be inserted into the config or into a plugin.
changelog:
type: structure
label: Changelog
limit: 1000
disabled: true
fields:
changelog_date:
label: Date
type: text
changelog_time:
label: Time
type: text
changelog_user:
label: User
type: text
@Oziris Even if the hook didn’t work, the error message says that you are calling changelog() on something that is not a page. Could you please post the code (with context), where you are calling this method?
Sorry, I overlooked the call to $field. But $newPage should already be a page object, without passing it as an argument to the page helper. So if you remove that in both instances and only use $newPage, it should work. I don’t know why that helper is used there.
When removing $fieldData = Data::encode($fieldData, 'yaml'); everything works fine but, i am not sure about the consequences
The code shows the index.php of my small plugin.
Also when enhancing with more hooks (e.g. changeTitle:after) updated:after is called as the changelog field resides in the same page. Is there anyway around this except moving changelog onto a separate subpage?
Update: removing $fieldData = Data::encode($fieldData, 'yaml'); didn’t help after all. It just disappears sometimes.
Any idea why this could happen @texnixe@Oli1 ? As to my understanding the page.update:after is called just once and not in a circle (as the hook changes the changelog which is a field of the page itself). Can you confirm?
yes, true, but this is intentionally as i just want to show the users human readable name in the changelog but store the user additionally in case a user is going to change his name we still now who “really” did the change.