Automatic Changelog Page (Create+Update Subpage Content)

Hello and TYIA for any help!

I have an interesting challenge that I know is possible but I’m trying to map out all the steps and could use some help.

Working on a project where essentially every page will have a subpage called /changes. That subpage will serve as a changleog for the parent page. Every update to the parent page should append information to the top of the /changes subpage.

The actual content of that changelog information is an editorially written field in the parent page, so I don’t need any kind of automatic before/after calculations or anything like that.

Here are the major specific needs I have that are a little over my head as of today:

  • The /changes subpage should be generated the first time the parent page is set to public and should include a boilerplate update text (regardless of what’s in the Changelog field) of “First publish.”
  • The /changes subpage should include my ‘lastudpateddate’ date alongside the Changelog text. It should also contain some TBD boilerplate and variable data (still working through this, but for example: maybe a subtitle of “Changes for the [parent page name]”, etc.)
  • After every saving (updating) of the page, the Changelog field in the parent page should empty, ready for the next editor to to put in her updates when next updating the page.

I’m sure I’ll come up with more, but that’s the gist.

I’ve very familiar with getting the new field in the panel - that’s easy. What I’m after is some guidance around the code required to pull off the stuff in the bullets above.

Anyone done anything similar and could share some code? If not, any basic direction?

THANK YOU!

That can be achieved with a page.changeStatus:afterhook: https://getkirby.com/docs/reference/plugins/hooks/page-changestatus-after. Inside that hook, you would create the subpage (see this cookbook recipe), and also update your newly created page with the boilerplate text.

That can also be achieved in the same hook.

In fact, all of this can be done with hooks, depending on when it should happen.

2 Likes

Perfect! Thanks!