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
Comment #2
pyrello commentedComment #4
pdureau commentedThis would be very helpful!
I don't think we need a new "layout" config entity. The existing entities seem already ok to implement that.
Comment #5
tim.plunkettSay 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]
Comment #7
pyrello commentedI would consider this blocked until https://www.drupal.org/project/drupal/issues/3208766 is resolved.
Comment #11
pyrello commentedI'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_uuidproperty. 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.