Blueprints
Blueprints are registered with the blueprints extension.
File definition
The blueprints extension accepts an array of key/value pairs, where the key is the name of the blueprint and the value the path to the file in your plugin folder.
Kirby::plugin(
name: 'your/plugin',
extends: [
'blueprints' => [
'pages/blog' => __DIR__ . '/blueprints/blog.yml'
]
]
);
The blueprint key must start with 'pages/...', 'users/...', etc. to activate the designated locations.
Array definition
Alternatively, you can also pass the blueprint definition as an array instead of a file:
Kirby::plugin(
name: 'your/plugin',
extends: [
'blueprints' => [
'pages/blog' => [
'title' => 'Blog',
'fields' => [
// ...
]
]
]
]
);
Callback definition
Plugins can now define dynamic blueprints based on config settings, content and other factors.
<?php
Kirby::plugin(
name: 'my/blueprint',
extends: [
'blueprints' => [
'pages/blog' => function ($kirby) {
return [
'title' => 'Blog',
'fields' => [
'articles' => [
'type' => 'pagelist',
'template' => 'article',
'limit' => $kirby->option('blog.article.limit')
]
]
];
}
]
]
);