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 edit? 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?