Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a mechanism for themes to prevent insertion of new blocks at root of block template part #42775

Open
fabiankaegy opened this issue Jul 28, 2022 · 1 comment
Labels
[Feature] Block API API that allows to express the block paradigm. [Feature] Block Locking The API allowing for the ability to lock/unlock blocks [Feature] Template Editing Mode Related to the template editor available in the Block Editor [Feature] Templates API Related to API powering block template functionality in the Site Editor [Type] Enhancement A suggestion for improvement.

Comments

@fabiankaegy
Copy link
Member

What problem does this address?

This came up while testing #42729. When a theme provides a block template part there are cases where the theme wants to wrap a template part in a single element and only allow the insertion of new blocks within that root. Let's take a site-wide notification area or even a Cookie banner as an example. As a theme author, I want editors to be able to visually edit the content of that template part. But I want to ensure that all the content is located within a full-width aligned group block.

I can already use the block locking attributes to prevent editors from being able to remove the wrapping group block for example. But I currently cannot prevent editors from inserting any additional blocks at the root level of the template part. Ideally, there would be a way similar to how the templateLock on custom post types works.

What is your proposed solution?

It would be great to be able to define a templateLock at the level of individual template parts. This could be achieved via a metadata header in the .html template part file. Or via the templateParts key in theme.json.

@fabiankaegy fabiankaegy added [Type] Enhancement A suggestion for improvement. [Feature] Block API API that allows to express the block paradigm. [Feature] Templates API Related to API powering block template functionality in the Site Editor [Feature] Template Editing Mode Related to the template editor available in the Block Editor [Feature] Block Locking The API allowing for the ability to lock/unlock blocks labels Jul 28, 2022
@mediaformat
Copy link

I just ran into this issue in a hybrid theme, the template part in question is called via block_template_part( 'example-block' ). In this case the proposed solutions (metadata header) would work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block API API that allows to express the block paradigm. [Feature] Block Locking The API allowing for the ability to lock/unlock blocks [Feature] Template Editing Mode Related to the template editor available in the Block Editor [Feature] Templates API Related to API powering block template functionality in the Site Editor [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

2 participants