Panel Page Modifications

Hey

I’m trying to create a Kirby plugin that would extend the functionality of the Panel, especially editing of pages.

However I’m stuck trying to find the best and cleanest approach without hacking around too much unnecessarily. I am considering

Essentially what I need is:

  1. identifying pages edit requests (so far using the path object)
  2. access the pages edit form (I need to add an extra button per page edit, next to Save)
  3. pick up requests made to a specific route on the panel

Currently, in my plugin I’m filtering panel requests only via

if (! function_exists('panel')) return;

I’m now stuck with the panel() object, but a lot of the properties there are inaccessible, like path for example (var_dump(panel()->path shows NULL). Although I can workaround that using the kirby() object, it feels like hackish already.

I’m also starting to wonder if it is at all possible to “plugin” into the forms, at least without having to hack the panel source.

Any feedback is highly appreciated!

Currently, there are only 3 ways to extend the panel:

  • creating custom form fields (quite powerful, you can use fields to so all kinds of stuff, a bit hackish at times)
  • panel widgets
  • custom panel views

If you want to do anything with the forms, you would have to create a field.

What exactly do you want to achieve?

I’m assuming you mean this: https://getkirby.com/docs/developer-guide/panel

I’ve read through them, and it seems nothing would help much with what we need. Perhaps you could have a better idea of how to use any of them for our needs. What we’re aiming at building is essentially a review mechanism for page edits. To spare you all the details of how we’re using Kirby, technically the result should be:

  • a special content/filestates.txt file that contains states for every file (example file: content/2-pets/cats/cat.en.txt)
    This special file would look something like this:
1;content/2-pets/cats/cat.en.txt
0;content/2-pets/cats/cat.es.txt
3;content/2-pets/cats/cat.de.txt
  • States can be changed by admins/non-admins via an extra button that is next to the “Save” button on the forms
  • Buttons submit a request to, e.g., panel/reviewed, and I’d listen on that and update the state files accordingly

A custom field would be the way to go.

Check out the list of Kirby plugins to see what can be done with fields: https://github.com/jenstornell/kirby-plugins/issues

Nice! This looks already like a good start. Thanks for that link! I’ll post back with updates to this.