Add layout_builder_ipe compatibility

Created on 19 September 2024, 7 months ago

Problem/Motivation

I recently stumbled upon the layout_builder_ipe module, which makes it possible to edit a layout directly on the node/entity page without going to the layout edit route. But when editing a block for example this way, the bootstrap styles are not loaded.

Steps to reproduce

- have a layoutbuilder entity/node type
- add and enable layout_builder_ipe, edit the entity view mode to 'Use the Layout Builder IPE frontend' so it shows an 'Edit' button when displaying the page/node/entity
- visit a layoutbuilder node/entity and click on the 'Edit' button provided by the layout_builder_ipe module
- edit a block or section just like you would on the layout edit page
- notice styling problems because bootstrap styles is not loaded

Proposed resolution

edit bootstrap_styles/bootstrap_styles.module and alter the bootstrap_styles_page_attachments_alter function: add module_handler service and check if the layout_builder_ipe module is enabled. If so, add the entity canonical route to $layout_routes:

  $settings = \Drupal::config('bootstrap_styles.settings');
  $entity_types = array_keys(\Drupal::entityTypeManager()->getDefinitions());
  $layout_routes = [];
  $moduleHandler = \Drupal::service('module_handler');

  foreach ($entity_types as $entity_type_id) {
    $layout_routes[] = 'layout_builder.defaults.' . $entity_type_id . '.view';
    $layout_routes[] = 'layout_builder.overrides.' . $entity_type_id . '.view';
    // layout_library module.
    $layout_routes[] = 'layout_builder.layout_library.' . $entity_type_id . '.view';
    // Module layout_builder_ipe allows editing from default node route.
    if ($moduleHandler->moduleExists('layout_builder_ipe')) {
      $layout_routes[] = 'entity.' . $entity_type_id . '.canonical';
    }
  }

Remaining tasks

- create MR or patch
- test
- commit

Feature request
Status

Active

Version

2.0

Component

Code

Created by

🇧🇪Belgium flyke

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024