Hugo
October 4, 2023, 8:44am
1
Hi,
Is it possible to extends a blueprint located in a plugin in a file located outside of the plugin ?
For example, I have my default.yml blueprint file located at /site/blueprints/page/default.yml
:
title: Simple Page
icon: ๐
columns:
main:
sections:
fields:
type: fields
fields:
layout: fields/custom-layout
And the file in my plugin located at /site/plugins/custom-layout/blueprints/fields/custom-layout.yml
label: Layout
type: layout
layouts:
- "1/1"
- "1/2, 1/2"
- "1/3, 1/3, 1/3"
- "1/3, 2/3"
- "2/3, 1/3"
- "1/4, 1/4, 1/4, 1/4"
I tried with this /site/plugins/custom-layout/index.php
, but it doesnโt seem to work:
<?php
Kirby::plugin('hugo/custom-layout', [
'blueprints' => [
'fields/custom-layout' => __DIR__ . "/blueprints/fields/custom-layout.yml",
],
]);
Hugo
October 4, 2023, 10:02am
2
ChatGPT gave me this solution, it seems to work pretty well, keep you informed if there is errors.
<?php
Kirby::plugin('hugo/custom-layout', [
'blueprints' => [
'fields/custom-layout' => __DIR__ . '/blueprints/fields/custom-layout.yml',
],
'fieldMethods' => [
'custom-layout' => function ($value) {
return $value;
},
],
]);
ChatGPTโs database only lasts until September 2021. Two years of missing knowledge is a long time for software changes. Glad you were able to find help there. My queries are always 90% out of context with Kirby and are useless. Pure PHP works just fine though, as long as you understand the code and can spot inconsistencies.
Wondering what the field method is doing there, it has nothing to do with the blueprint.
Your original example should have worked, unless your file path was wrong, or you have a typo somewhere.
Hugo
October 4, 2023, 12:35pm
5
Yes, I checked and it work without the fieldMethods, it was probably a typo ^^โ