I just created a custom block plugin following the screencast Block Plugin Crash Course. Everything works so far but I have a problem with the template. The block consists of a text field used for a heading and a textarea for a text.
Vue components (which such a Panel plugin is basically rendered as) need a single DOM element as their template. This will change once we migrate to Vue 3 in Kirby 6 (likely), but for the moment, your template code needs to be a single node, not two parallel ones.
I agree that it would be great without it but there we just need to follow what Vue requires. Don’t try to fight it, it’s not worth it and while I understand the desire for tidiness this is fine - your efforts will be more worthwhile on other aspects
Now, I have another problem. I would like to have the same panel styles and structures for the elements. How do I achieve this? I know about lab.getkirby.com.
Thanks! The styling is fine now but the sync does not work anymore. Why does this happen? If I edit the fields in the regular block editing section the contents change but not vice versa.
You still need the methods, but instead of receiving event and updating event.target.value, your methods receive the value directly and can use it to update.
No, as I wrote, you keep the method call as is (@input="editToggle") but your method receives value instead of event and also uses value for the update call:
editToggle(value) {
this.update({
toggle: value
})
}
Thanks. Now the fields sync but the placeholder does not sync with the blueprint anymore. Why? I used, for instance, placeholder="field('text').placeholder" to achieve this.
The blueprint places a toggle next to the heading. This is not the case in my custom form. How can I adapt the layout of my form to that of the blueprint?
Question: are you just trying to recreate 1:1 the fields from the drawer in your block preview? If so, I’d recommend to rather go with Blocks | Kirby CMS
Yes, I do. I plan to create some structure-based blocks as well. As far as I know, these do not work with wysiwyg. That is why I try to create such a workaround.
Please see the screenshots. I am planning an accordion <details> block with a heading that can be hidden by display: none. The heading is important for the semantic structure and appears in the source code even if it is not to be displayed. I am also planning a table block with a heading that can be hidden. Hence the toggle field next to the heading fields.
It would be nice if the input mask appeared just as minimally in the panel as Kirby’s own blocks.
Each block will be a <section> of an <article>. Accroding to W3Schools, section and article elements require a heading element. My HTML semantics will be structured like this:
My plugin works well so far. At the moment, I just do not know how to apply the width and the placeholder defined in the blueprints. Is there an easy way like you showed me with the single fields?