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": [...]
        }
    ]
}
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

arthur_lorenz created an issue. See original summary.

fago’s picture

Issue summary: View changes
fago’s picture

Priority: Normal » Critical

fago’s picture

Title: Option to output fields beside a layout » Output configured fields beside a layout
Status: Active » Needs review

I 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.

fago’s picture

Title: Output configured fields beside a layout » Continue to output configured fields when layout builder is activated

better title

useernamee’s picture

Status: Needs review » Reviewed & tested by the community

PR 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.

  • fago committed 9dfbd7b3 on 3.x
    Issue #3524432 by fago: Continue to output configured fields when layout...
fago’s picture

Status: Reviewed & tested by the community » Fixed

Thanks 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!

Status: Fixed » Closed (fixed)

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