Problem/Motivation

My site's users would like the ability to clone pages with custom layouts crafted in Layout Builder. Unfortunately, the current "Copy values" field processor is not quite up to the task and results in cross-talk issues between the original and cloned layout.

Proposed resolution

Add a new field processor specifically for the 'layout_section' field type that can properly clone an entity's layout (without the cross-talk issues that come with a basic field value copy).

Remaining tasks

Patch + review.

User interface changes

New field processor option for Layout Builder layout fields.

API changes

None.

Data model changes

None.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

chrisolof created an issue. See original summary.

chrisolof’s picture

Merge request created. Working so far across a variety of complex layouts in my initial tests.

- New "Copy layout" field processor plugin, only offered for layout builder layout type fields.
- Clones each section inside of the layout
- Clones each component inside of each section, giving each component its own UUID. UUIDs are not intended to be shared.
- If component is a layout builder-provided content block, the content block is also cloned (at the revision specified by the component). These blocks are not intended to be shared across layouts. Cloning these blocks prevents cross-talk issues between original and cloned layouts. Block clone is done content_entity_clone-style if clone settings are enabled for the block type, falling back to a core entity clone.
- Copy values plugin adjusted to not show up for layout builder layout type fields, as it is inappropriate for that field type.

Needs review and additional testing.

Attached patch represents the current state of MR8 at the time of this comment.

chrisolof’s picture

Status: Active » Needs review
orakili’s picture

Status: Needs review » Reviewed & tested by the community

Tested with simple layouts and it seems to be working well. The code is clean. Thank you.

  • orakili committed 7503032c on 1.0.x
    fix: #3491781 - check that the block_content entity type exists
    
orakili’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.