Preview section in library (main theme like layout builder content design tab)

Created on 16 October 2023, about 1 year ago

Problem/Motivation

It would be great to have the possibility of preview each section using main theme instead of the admin one as in cannonical entity route & showing rendered "layout_section" as it would do when imported in layout builder content design page.

Steps to reproduce

Go to "Content" -> "Layout builder library" -> (Choose one) "Operations links" -> "Preview": "/admin/content/section-library" -> (example) "/admin/content/section-library/32/preview".


Or configure Label in view "/admin/structure/views/view/section_library" with rewrite results as link with "/admin/content/section-library/{{ id }}/preview" & do same as described but click in each section label.

Proposed resolution

Add a new controller to facilitate that feature & include as entity preview link.

Remaining tasks

Confirm approach or iterate like proposed below.

User interface changes

Editors with "view section library templates" access (same as required to enter the main sections view) will be able to preview sections without having to include it into content just to check how it would look like (like manual screenshot but "live", updated, automatically & large enough, screenshot may be shown in low dimensions within import from library).

Data model changes

None for initial version using "entity_id" to use it as context (required in many cases to build sections correctly).
That approach has a disvantage as if entity where section was saved is removed, that context can't be used, using section otherwhise but may not show some blocks that requires specific entity like node body block.


A sample entity can be generated by "\Drupal::service('layout_builder.sample_entity_generator')->get($entity_type_id, $entity_bundle_id)," but those paramenters are missing in entity data, also consider that for sections saved from display configuration "https://drupal.org/i/3263496" stored entity type is "entity_view_display".


An iteration maybe would be to store entity type id & bundle of entity where section is saved, or section storage id?


Other complementary option would be to replace cannonical like media does if a configuration is enabled "standalone" or by default as display seems not configurable by ui & sections are not shown.

Feature request
Status

Needs review

Version

1.1

Component

Code

Created by

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

Comments & Activities

Production build 0.71.5 2024