Where have I gone wrong? I just tried to follow the steps on the github.
plugins/custom-blocks/index.php
<?php
Kirby::plugin('yourname/custom-block', [
'snippets' => [
'editor/accordion' => __DIR__ . '/snippets/accordion.php'
]
]);
plugins/custom-blocks/index.js
editor.block("accordion", {
label: "Accordion",
icon: "template"
});
plugins/custom-blocks/snippets/accordion.php
<p class="test"><?= $content ?></p>
When I go to the panel - I now just get The field type "editor" does not exist
Ah I see. Ok. I’ll name it editor-custom
If I want to have multiple editor blocks within this plugin how would I go about organising it? or Can I not do this.
Haha.
So for example
I couldn’t do
editor-custom
- accordion
- - snippets/accordion.php
- - index.js
- - index.php
- quote
- - snippets/quote.php
- - index.js
- - index.php
I would need to do this instead?
editor-accordion
editor-quote
as separate plugins?
texnixe
6
That structure is definitely not possible, because the main folder needs an index.php (and a main index.js file), otherwise the plugin is not loaded.
either that or have a single plugin that contains all of them:
editor-custom-blocks/index.php
<?php
Kirby::plugin('yourname/custom-block', [
'snippets' => [
'editor/accordion' => __DIR__ . '/snippets/accordion.php',
'editor/harmonica' => __DIR__ . '/snippets/harmonica.php',
'editor/flute' => __DIR__ . '/snippets/flute.php'
]
]);
editor-custom-blocks/src/index.js
import { accordion } from './components/accordion.js'
import { harmonica } from './components/harmonica.js'
import { flute } from './components/flute.js'
editor.block("accordion", accordion);
editor.block("harmonica", harmonica);
editor.block("flute", flute);
Then have a javascript build process (something like parceljs) compile your main index.js file
Yes, many thanks for explaining, I figured this out late Friday evening in the end after reading the kirby plugin documentation.