I would like to add panel areas just from yml the same way I use tabs:
E. g. in site.yml
:
title: Site
sections:
mySection:
...
tabs:
myTab:
...
areas:
myArea:
....
I would however also like to register a YAML file as a panel area from within a plugin.
E. g.
Kirby::plugin('tooloop/guide', [
'areas' => [
'myArea' => Blueprint::load(__DIR__ . '/blueprints/myArea.yml'),
],
...
]);
Where would custom areas like this their content - and what would be the difference to creating a unlisted page for the area?
hm, interesting. I was assuming I it was the upmost hierarchy and just like tabs in the site.yml it would store the content in site.txt.
I’m not aware, you could use an unlisted page as panel area?!
@Daniel.stock Pages (no matter if listed or unlisted) can be added as links in the panel sidebar (https://getkirby.com/docs/reference/system/options/panel#panel-menu), not really as areas.
Also, areas do not store there content in site.txt, unless you somehow make them do.
Yes, this is essentially what I wanted to say.
For the panel user it looks like an “area” but it’s actually just an unlisted page that’s added to the sidebar.
That’s a nice solution.
However, I can’t figure out, how to register those from within a plugin without touching the users config.php
That is not possible but it’s also not an issue for the users (at least I haven’t got any reports about it). DreamForm does it that way.
hm, it kind of is to me :-/
I really would have hoped to at least get something like this running:
Kirby::plugin('tooloop/guide', [
'areas' => [
'tooloopGuide' => function ($kirby) {
return [
'label' => 'Tooloop Guide',
'icon' => 'map',
'menu' => true,
'link' => 'guide',
'views' => [
[
'pattern' => 'guide',
'action' => function () {
return [
'component' => 'k-page-view',
'props' => [
'blueprint' => 'guide'
],
];
}
]
]
];
}
],
// ...
]);
This acuallty adds a link in the menu and shows an info box in the panel, stating you could add fields in /site/blueprints/pages/guide.yml
.
But it doesn’t work.
Wait, I think I can work it out.
This does what you suggested from my plugin. :-)
Kirby::plugin('tooloop/guide', [
'areas' => [
'tooloopGuide' => [
'label' => 'Tooloop Guide',
'icon' => 'images',
'menu' => true,
'link' => 'pages/guide',
'current' => function (string $current): bool {
$path = Kirby::instance()->path();
return Str::contains($path, 'pages/guide');
},
],
'site' => [
'label' => t('pages'),
'current' => function (): bool {
// the links of all your custom menu entries
$links = ['pages/guide'];
$path = Kirby::instance()->path();
return
Str::contains($path, 'site') &&
A::every($links, fn($link) => Str::contains($path, $link) === false);
},
],
]
]);