- π¨π¦Canada liquidcms
Patch applies to latest dev and mostly works. The "title" is being set but the metatitle is still showing as the title used to create the page.. which doesn't seem to be editable.
- π©πͺGermany Anybody Porta Westfalica
Could someone please turn this into a MR instead of patches?
- First commit to issue fork.
- @goz opened merge request.
- πΏπ¦South Africa daniel bornman
The patch works for me but I ran into a bit of an edge case here - the current
LayoutBuilderDisplayVariant::build()
implementation as in the patch / pull request builds blocks in the order they were added, not their weight asDrupal\layout_builder\Section::toRenderArray()
would.Leveraging
Drupal\layout_builder\Section::getComponentsByRegion()
to sort the blocks by weight as inDrupal\layout_builder\Section::toRenderArray()
, fixes the issue:/** * {@inheritdoc} */ public function build() { $build = []; $contexts = $this->getContexts(); $in_preview = FALSE; /** @var \Drupal\layout_builder\Section $section */ foreach ($this->getSections() as $delta => $section) { $layout_definition = $section->getLayout()->getPluginDefinition(); foreach ($layout_definition->getRegionNames() as $region) { foreach ($section->getComponentsByRegion($region) as $component) { if ($block = $component->toRenderArray($contexts, $in_preview)) { if ($this->configuration['title_type'] === 'block' && $this->configuration['title_from_block'] === $uuid) { $build['#title'] = $this->getBlockTitle($block); $block['#configuration']['label_display'] = 0; } $regions[$component->getRegion()][$component->getUuid()] = $block; } } } $build[$delta] = $section->getLayout()->build($regions); } if ($this->configuration['title_type'] === 'manual') { $build['#title'] = $this->renderManualPageTitle($this->configuration['manual_title']); } return $build; }
- πΏπ¦South Africa daniel bornman
I'm attaching a patch with the change I described above, for reference. It adjusts the build order by using
Drupal\layout_builder\Section::getComponentsByRegion()
, aligning withDrupal\layout_builder\Section::toRenderArray()
behavior and fixing the edge case with block weights.