-
Notifications
You must be signed in to change notification settings - Fork 5
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 layout builder support for the Services blocks #116
Comments
Ref #116 Add the node context to the service blocks, this allows them to be used with layout builder
Going to try and revive this one post beta to work out what the blockers where. |
Ref #116 Add the node context to the service blocks, this allows them to be used with layout builder
So the blocker will be that sites block config for service blocks will need to be updated and resaved to add the context. $entity_type_manager = \Drupal::entityTypeManager();
$blocks = $entity_type_manager->getStorage('block')->loadByProperties([
'plugin' => 'SERVICE_BLOCK_PLUGIN_ID',
]);
foreach ($blocks as $block) {
if ($block->getRegion() == 'my_region') {
$settings = $block->get('settings');
// modify settings
$block->set('settings', $settings);
$block->save();
}
} It needs node: '@node.node_route_context:node' adding as a context mapping eg. settings:
id: localgov_services_related_links_block
label: 'Service page related links'
label_display: '0'
provider: localgov_services_page
context_mapping:
node: '@node.node_route_context:node' |
Ref #116 Add the node context to the service blocks, this allows them to be used with layout builder
When using layout builder with service content types, there's a case for adding the blocks into the layout (although custom field formatters would be better).
The Service CTA blocks, Related topics and Related links blocks don't work correctly inside layout builder. They rely on the current page route to work out the node id, without this the blocks fail as $this->node is not set and an empty check is needed to avoid a WSOD when adding the block.
A node context should be provided for these blocks (in ServiceBlockBase?) This allows the blocks to work with live preview and layout builder instead of displaying 'placeholder for'
![Screenshot 2021-06-01 at 10 54 54 pm](https://user-images.githubusercontent.com/1467480/120395172-798a0d80-c32c-11eb-808c-27028c664999.png)
.The text was updated successfully, but these errors were encountered: