How to Automatically Configure required and disableNewBlocks for a Custom Content Type in Volto Add-On

Hi everyone,

I'm working on a Volto add-on where I need to create a custom content type that should consist of only two blocks: a title block and a listing block.

Here's what I've done so far:

  • Initialization: I'm using initialBlocks to initialize the content type with the title and the listing block.
  • Overwrite the Title Block Edit Component: I’ve allowed disableNewBlocks to be true if data?.disableNewBlocks is true in Title.
  • Manual Configuration: In the Volto content type editable layout, I manually set the required and disableNewBlocks properties to true for these blocks. This ensures that no additional blocks can be added, and the two initial blocks are required.

My Questions:

  • Automating required and disableNewBlocks: Is there a way to automatically configure required and disableNewBlocks (i.e., via schema, FTI etc.) for these blocks when the content type is created, so the user doesn't have to set these properties manually in the content type layout?
  • Component Shadowing for the Custom Content Type Only: Is there a way to overwrite the title component for the custom content type only so that it has no effects on others?
  • Alternative Approaches: Is there another, possibly better, way to enforce that the content type should only contain these two blocks, without allowing the addition of any other blocks?

Thanks for any insights or suggestions!

2 Likes

Alternative Approaches : use volto-group-block
you can easily create a new content type and set the blocks a title and listing block as the only two allow blocks

1 Like