Problem/Motivation

Right now, the only option for resetting a layout is to reset to the default layout, which will wipe out all custom content that has been added via LB. However, there is oftentimes a need to reset a part of a layout without blowing up then entire thing. This issue is a placeholder for a more fleshed out version until it can be produced.

Proposed resolution

Since this is early days, here are a few ideas off the top of my head. Currently, the default layout is stored as a bunch of settings on an entity_view_display config. In the future, it might make sense to have layout templates stored as their own config definition and referenced via entity_view_display. Additionally, all original sections from a default layout template would have some sort of UI to restore them. If an original section had been modified, it could be restored. If it had been deleted, it could be restored.

Remaining tasks

* Figure out the scope of this task.

User interface changes

* Section option to restore to default.
* Perhaps a toggle to show default sections that had been deleted along with an option to restore them.

API changes

TBD

Data model changes

Probably... TBD

Comments

pyrello created an issue. See original summary.

pyrello’s picture

Issue tags: +Blocks-Layouts

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

pdureau’s picture

This would be very helpful!

I don't think we need a new "layout" config entity. The existing entities seem already ok to implement that.

tim.plunkett’s picture

Say you have a default layout for article nodes. It contains two sections:
- a 2 column section with an Image in the first region, and the Title in the second region
- a 1 column section with the Body in the main region

On an individual node, you override the layout and add a new section to the top of the node
- a 3 column section with the Published Date in the first region, the Author name in the second region, and the Tags in the third region

Then you change the default layout, by swapping the Image and Title.

You go to your individual node, and want to revert the section with Image and Title to match the default.
However, when you do so, you end up with
- a 3 column section with the Published Date in the first region, the Author name in the second region, and the Tags in the third region
- a 1 column section with the Body in the main region
- a 1 column section with the Body in the main region

Which is not what you want!

This is because the sections are stored as a sequence.
The default has a section at 0 and 1. Your override had the same at 0 and 1 but they became 1 and 2 when you added a new section to the top.

Note this will become even more complicated with #3080606: [PP-1] Reorder Layout Builder sections.

Given a section of an overridden layout, there's no way to know which section on the default it corresponds to.

This was a key feature that the original attempted Layout Initiative from 2012, but it was never solved there either: #1812720: Implement the new panels-ish controller [it's a good purple]

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

pyrello’s picture

Status: Active » Postponed

I would consider this blocked until https://www.drupal.org/project/drupal/issues/3208766 is resolved.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

pyrello’s picture

Status: Postponed » Closed (won't fix)

I've had reason to consider this request again while working on #3208766: Add UUID to sections. Looking at this with fresh eyes I can now see that this would be very complex to implement. When a section was overridden from the default, you'd need to capture the UUID of the section from the original layout and store it as an original_uuid property. This would only work if you made modifications to the section that was overridden. If you removed that section and added another one where it had been, there would be no way to trace it back to the original. This means that if you needed to switch to a different section layout (such as going from two columns to one column) you would have no way to do that and preserve the connection to the original.

This might make sense in some far-future version of Layout Builder that is greatly advanced past where the current version of it is, but is probably a bonkers request at the current time. I'm going to close it to reduce the noise a little bit.