Panel sidebar widgets has been discussed before but there has been no clear solution to how it should be done. Here is an idea of how…
Blueprint
title: Projects
fields:
title:
label: Title
type: text
widgets
page_settings:
label: Page settings
type: page_settings
my_custom_widget:
label: My custom widget
type: my_custom_widget
pages:
label: Pages
type: pages
files:
label: Files
type: files
-
page_settings
,pages
andfiles
are Kirby built in widgets. -
my_custom_widget
is my own widget that I’ve placed between them.
Fallback
If widgets
does not exists in the blueprint, fallback to the built in page widgets. It makes it a non breaking feature.
If labels are not added to built in page widgets, use the built in ones.
To register the widget it could be done kind of like this:
$kirby->set('page::widget', 'my_custom_widget', __DIR__ . '/page-widgets/my_custom_widget');
I’m not sure about the name but see it as an idea.
Why blueprint for page widgets
- The panel page uses a blueprint for all the fields so why not for page widgets as well.
- Sorting is a breeze within a blueprint (move text around).
- The blueprint already exists so there is no need to invent something new.
- When using the same blueprint file for the fields and page widgets, everything in that panel page is controlled by this blueprint.
- Probably easy for the crew to build as most of the work is already done, with blueprint parsing ect.
- It’s a non breaking feature. If the blueprint is used for older Kirby versions it will just ignore the widgets part.
- If I remember correctly blueprints have support for multiple languages as well?
Isn’t this THE perfect solution to the problem? It feels like I nailed it!