Problem/Motivation

Motto:

  • Block module’s scope is to place blocks.
  • Layout Builder module’s scope is to place blocks.

Block placements are decentralised. Each block placement is an config entity. Many modules can work together to place blocks on the same page. In other words a module providing a block placement, shouldn’t know if a different module provides also a placement on the same page or even on the same region.

Layout Builder placements are centralized. All the block placements are living in a single object (e.g. as 3rd-party settings of the entity view display). This means that the underlying object should know that the modules providing the block exists. As an effect, the object providing the block placements has hard dependencies on modules providing the blocks. Third-parties are not able to hook-in by themselves, they should be dependencies of the module that provides the object providing the placements.

Illustrating the issue

A landing page, assembling blocks, built with Layout Builder & Page Manager. Each block is provided by different modules, which are reusable units. This means that some projects might want not to use one or more of the modules that are providing the blocks. This not possible right now as the landing page config will have hard dependencies on the modules providing the blocks. This is possible with the Block module as each module is able to ship their block placements.

Proposed resolution

We need a mechanism that allows a module to hook-into the layout even with the layout knowing nothing about the module existence:

Problems to be solved:

  • There's nothing similar to LayoutBuilderEvents::SECTION_COMPONENT_BUILD_RENDER_ARRAY event, but on a section level (i.e. SECTION_BUILD_RENDER_ARRAY). This would allow 3rd-party to intercept the produced render array and inject additional components/blocks into the section. A 3rd-party would listen to that event and would ask all modules if they want to provide block placements.
  • How to represent these "alien" placements in layout editor? Can we use something similar to placeholder text, to indicate that block is provided by a certain module and cannot be configured/removed in the layout editor?

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3210230

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

claudiu.cristea created an issue. See original summary.

claudiu.cristea’s picture

Issue summary: View changes
claudiu.cristea’s picture

Issue summary: View changes
claudiu.cristea’s picture

Title: Block placements by 3rd-party » Block placements by 3rd-party in layout section
claudiu.cristea’s picture

Status: Active » Closed (duplicate)

@tim.plunkett pointed me to #3062862: Third party should be allowed to alter the section render array and #3101655: Layout section and component information accessible during render process. At least, regarding the new event, this is a duplicate. My plan is to help getting #3062862: Third party should be allowed to alter the section render array committed and, later, create a contrib, as PoC, with potential core adoption.

Closing this as duplicate of #3062862: Third party should be allowed to alter the section render array.