yup, here you go!
index.php
<?php
use Kirby\Cms\App as Kirby;
Kirby::plugin('cookbook/dynamic-blueprints', [
'blueprints' => [
'pages/meals' => function ($kirby) {
return include __DIR__ . '/blueprints/pages/meals.php';
},
]
]);
meals.php
<?php
$sections = [];
if ($page = page('meals')) {
// create dynaimic sections
foreach ($page->site()->find('categories')->children() as $category) {
$sections[explode('/', $category)[1]] = [
'headline' => $category->title()->value(),
'type' => 'pagesdisplay',
'status' => 'published',
'layout' => 'cardlets',
'empty' => 'No products yet',
'query' => "page.children.filterBy('type', '==', '" . $category . "')",
'templates' => 'meal',
'image' => false,
'info' => '{{ page.descr }}'
];
}
// add drafts
$sections['drafts'] = [
'headline' => 'Drafts',
'type' => 'pages',
'status' => 'draft',
'empty' => 'No products yet',
'templates' => 'meal',
'image' => false,
'info' => '{{ page.descr }}'
];
}
// create the array for the page blueprint with two columns
$yaml = [
'title' => 'Meals',
'image' => [
'back' => 'white',
'icon' => 'food',
'color' => 'black'
],
'options' => [
'changeSlug' => false,
'changeStatus' => false,
'changeTemplate' => false,
'changeTitle' => false,
'delete' => false,
'preview' => false,
'update' => false,
'duplicate' => false
],
'sections' => $sections
];
return $yaml;