Hi everyone!
On a website I defined some custom block blueprints.
Inside of these blocks I have info fields for guiding the editor and explaining how that particular block works inside the panel.
In the info field’s text I want to access the associated custom block’s id, to link to an anchor on an internal custom block overview page (where the block ids are used for on page navigation).
I tried some things like
fields:
info:
type: info
text: >
{{ block.id }}
or
{{ fieldset.id }}
and a couple other things. But that doesn’t seem to work.
I also would like to access the block’s type to load a particular screenshot.
Is it possible to access info about the block inside a field?
I am using the newest Kirby 4 Beta.
Thank you very much
Hm, I’d say at the time the block is about to be created, and when the user would need this information, the block id is not defined yet, but only when the block is stored.
Thanks for your fast answer
Okay! That’s understandable. What about the block’s type?
I was thinking about storing screenshots of every custom block in a folder and name the screenshots by the blocks’ types. So I can access the right screenshot from the panel inside the block. Would that be possible (without custom plugins)?
No, I don’t think you have access to that either, but on the other hand you know your block type when you add the info field in your block type blueprint anyway, so might as well hard-code the type?
info:
type: info
text: <a href="{{site.url}}/blocks/mycustomblock">Check out an example block preview</a>
Hi Sonja,
ahh, yes, of course! That totally works, I really did not think about just hard coding it in the first place.
Sometimes have 30+ custom blocks per project (all extending the same base block blueprint), I thought to maybe achieve a “one line” result. But if you can’t access these infos, hard coding is totally fine.
Thanks again and have a great weekend!