I have a question regarding the Blocks Field. I have a blocks field that can contain a bunch of different blocks like image galleries, texts and so on. So far nothing special. But I do have one special block. That block should be present in every instance of the Blocks Field exactly once.
I wonder if there is some blueprint magic to configure the block builder in such a way or if I would have to do that myself using hooks. If it’s the latter would this strategy work? Sorry for the ugly pseudocode
page.create:after hook if (page contains block-field): specialblock = new Block('specialblock-content') blockfield.addBlock(specialblock) page.update:before hook if (page contains block-field) if(page->blockfield->toBlocks()->filterBy("type", "specialblock")->count() !== 1) throw new Exception('block field needs to contain one specialblock')
Has anybody dealt with a similar situation and has a good solution?
Thanks for your help!