Problem/Motivation
In the entity_ce_display, we want to have an option to output fields additionally to the layout. The idea is to give us better control over field rendering in our frontend components while also being able to place blocks in a layout. Currently we can either output fields or a layout.
E.g. Placing a view block with related nodes, while still controlling the node rendering using the node type's default frontend component.
Proposed resolution
* Keep the "manage-CE" display configuration applying - as it is the case when rendering without layout builder
* Keep rendering layout-builder into "sections" as done already, but have it next to the other output
The node ce output should look similar to this:
{
"element": "node-page",
"created": "1736421462",
"title": "My custom page",
"body": "<p>The is my content</p>",
"sections": [
{
"element": "drupal-layout",
"layout": "layout_onecol",
"content": [...]
}
]
}
Issue fork custom_elements-3524432
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
Comment #2
fagoComment #3
fagoComment #5
fagoI added the MR. The changed logic is nicely covered by the pre-existing test-case, so there is no need to create a dedicated one for this change. However, I noted that we lack coverage for testing that the generated CE for the layout-builder itself works properly, thus opened #3527490: Better test-coverage for layout builder support for it. Fortunately, there was no need to touch this part here, so it's not a problem to continue without it atm.
The change implements the configured behavior without introducing a new option. Generally, there is no need for one, since all fields can be removed from the configuration to get to the same result. Because of that, I prefer to not introduce another option to avoid the convolution of UI/config with many options.
That said, this is a change that potentially changes the API output for existing sites, i.e. if someone left the fields in the configuration, they are going to be output now. Thus, I'll create a change record. we are going to tag 3.1 anyway, so it's acceptable to have some larger change in there also.
Comment #6
fagobetter title
Comment #7
useernamee commentedPR looks good to me.
For BC we could add an additional checkbox to add fields to CE display. A config option that is only visible if layout builder is checked and disabled by default.
Comment #9
fagoThanks for reviewing!
>One idea that I had to have more backward compatibility is to add additional checkbox to add fields to CE display. A config option that is only visible if layout builder is checked and disabled by default.
True. Generally, it seems a bit duplicating since you could simply remove all fields. So considering new sites, the checkbox seems unnecessary duplication and it would be better to not have the checkbox. However, I agree that it would be nice for the upgrade path.
Another idea: Write an update function that removes fields for displays which have layout builder enabled. That way we do not clutter the UI and have a save update. I'll make a follow-up to clarify details!