Hello,
I am relatively new to programming in PHP and JS but I am giving my best. Kirby is a great tool and it really makes a lot of fun to create. But now my skills reached their end.
I tried something for a web project: I want to implement a (custom) blocks field, where you just see the heading in the blocks preview - not everything blocks type. There are some entries with a lot of text and it would become very confusing in the panel.
It should be looking like this:
But these are structured fields combined with a blocks field.
I am looking for a solution just with blocks field. I created a custom blocks type (servicesbox) in the blueprint:
blocks:
type: blocks
pretty: true
fieldsets:
- servicesbox
Here is the blueprint:
type: servicesbox
fields:
servicesContent:
type: blocks
pretty: true
fieldsets:
- heading
- text
- list
Nested blocks, because I would like to use the predefined field-types heading and list.
I created a custom blocks preview (like in the screencast “custom blocks plugin crash course”)
But my problem: it is a nested blocks array and I don’t know how I can filter or find the first heading of the custom blocks array (in “computed”). I just would like to show only the first or main heading in the preview.
Here is my index.js of the custom blocks preview plugin:
panel.plugin("cbkt/servicesbox", {
blocks: {
servicesbox: {
computed: {
???
},
methods: {
onInput(event) {
this.update({
text: event.target.value
}
);
}
},
template: `
<div>
<input
type="text"
:value=" ??? "
@input="onInput"
/>
</div>
`
}
}
});
In computed I have to find the heading of “servicesContent” blocks array and then I can write the value into the input field? I don’t know if this is correct but It should work. I tried with filter and find - but somehow I am missing something.
I searched a lot but could not find an answer. Will try the beginners tutorial for Vue 3 as well.
Appreciate any hints and help!
Thanks!
Chris

