Support using component block on a layout using layout builder without an entity context

Created on 13 July 2025, 19 days ago

Problem/Motivation

I'm using the module Page Manager to set up a generic page. This module supports me to build a page by using layout builder. I'd like to place blocks that are created from SDC to regions and I run into an error
Drupal\Component\Plugin\Exception\ContextException: The display context is not a valid context. in Drupal\layout_builder\Plugin\SectionStorage\SectionStorageBase->getContextDefinition() (line 150 of /var/www/html/web/core/lib/Drupal/Core/Plugin/ContextAwarePluginTrait.php).

After spending some time digging into the code, I see that when I use layout builder, the blocks I place in the layout is EntityComponentBlock, and these entity blocks require an entity context, which does not exist if I use Layout Builder in Page Manager module. So I think, in my case, instead of placing entity component blocks, I just need to use component blocks, and I came up with a patch :-) Happy to have someone review my patch. Thanks!

✨ Feature request
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States sea2709 Texas

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024