We have a field (name: modules, type: block) and the fieldset has 5 modules.
We would like to use $page->createChild([]) to create a specific block by code.
Unfortunately I can’t find a suitable example and would be very grateful for any hints.
We have a field (name: modules, type: block) and the fieldset has 5 modules.
We would like to use $page->createChild([]) to create a specific block by code.
Unfortunately I can’t find a suitable example and would be very grateful for any hints.
This recipe should help: Quicktip: Add blocks to a blocks field programmatically | Kirby CMS
Will also work when creating pages, of course.
Perfect, works wonderfully.
One more additional question:
How can we copy and create images from an external source in this context? So that we directly create the necessary text file.
I found the perfect example for it: Create file from url - #4 by scsskid