Problem/Motivation
The Field UI allows the rearranging of fields for a given piece of content, both for the authoring form and for the content display.
Each type of content can have multiple "view modes" (full, teaser, etc.), each which can have their own arrangement of fields. There is no concept of regions or sections, the fields can only be ordered.
In the contributed module space, modules like Panelizer and Display Suite enhance the display of content by adding support for layout, alongside many other functional improvements.
Also currently a contributed module, Layout Plugin is a module that drives the Layout mechanism of the above modules, but has no UI of it's own. It simply discovers and exposes layouts as an API.
Proposed resolution
Add the ability to choose a layout for each view mode, within Field UI.
Because entity displays are used for forms, this will allow site builders to customize the layout of the authoring form. Fields can be shown or hidden, and rearranged into any chosen layout. Each type of content can have multiple "form modes", each with a layout.
Entity displays also control the rendering of content. Different "view modes" are used when content is displayed in different places: shown as a paged list of teasers, when displayed in a sidebar as a bulleted list of titles, when shown as a canonical representation on its own page, etc.
These too can each have their own layout, with fields rearranged and toggled as necessary.
The first iteration will begin by hardcoding a few example layouts (one with top/bottom, one with left/right).
Proposal roadmap
Must-have
- In order for Field Layout to become stable, the Layout API on which it depends must be stable first. So every must-have for #2811175: [plan] Add layouts to Drupal also is a must-have for this module.
- #2840832: Add layout templates based on Panels layouts to core
- Usability review of UI texts
- Complete module handbook page as linked from
hook_help()
- Usability and accessibility review and testing of the user interface. (Out of scope: fixing existing usability and accessibility problems with the field UI.)
Should-have
- #2844302: Move Field Layout data model and API directly into \Drupal\Core\Entity\EntityDisplayBase
- Theme system maintainer review of theme implementations.
- Fix usability bug: Clicking save before the layout selector's AJAX behavior has completed results in the layout change not being saved, resulting in lost user input. See #2796173-172: Add experimental Field Layout module to allow entity view/form modes to switch between layouts and #2796173-176: Add experimental Field Layout module to allow entity view/form modes to switch between layouts.
- #2846389: Ajax progress indicator from layout settings is confusing
- #2846393: [PP-1] Investigate alternative approaches to moving fields in FieldLayoutBuilder::buildView()
- The collapsed layout fieldset at the bottom of the form difficult to discover, especially since it's after the "Custom display settings" fieldset on the default display. I might expect it to be at the top of the page. Is the reason that it's collapsed and hidden that we expect other modules will add settings there? Otherwise, it probably doesn't need to be in a fieldset at all.
- Discuss whether field_layout code should be moved into EntityDisplayBase and Field UI once it is ready to be stable, and how to ensure a smooth transition for sites and modules if so.
Could-have
- #2820210: Add Settings Tray support to field_layout
- #2846395: Increase module weight of field_layout
- Per-entity overrides
- Front-end UI to change layouts (determined to only be desired after per-entity overrides lands
- Explicit followup issue added to the
@todo
for:
+++ b/core/modules/field_layout/src/Entity/FieldLayoutEntityViewDisplay.php @@ -0,0 +1,24 @@ + public function getDefaultRegion() { + // This cannot be provided by the trait due to + // https://bugs.php.net/bug.php?id=71414 which is fixed in PHP 7.0.6. + return $this->getLayoutDefinition($this->getLayoutId())->getDefaultRegion();
and similar in
core/modules/field_layout/src/Entity/FieldLayoutEntityFormDisplay.php
. - Full integration with Context system to allow Panels-esque placement of other non-field content (block placement in Field UI?!)
Not in scope
Remaining tasks
Create child issues
Comments
Comment #2
tim.plunkettThis plan was discussed by the following people:
Gábor Hojtsy, xjm, japerry, tim.plunkett, Bojhan, DyanneNova, stevector, dsnopek, ted.bowman, alexpott, yoroy, dobe, hestenet, Crell, swentel, aspilicious
Comment #3
tim.plunkettFirst child issue: #2796173: Add experimental Field Layout module to allow entity view/form modes to switch between layouts
Comment #4
xjmComment #5
tim.plunkettIn the child issue, I've started on an experimental module called "Field Layout", which is just what I picked to get started.
@swentel suggested "Entity Layout", since we're not configuring the layout of the fields, but of the entity.
@Wim Leers further pointed out that we're dealing with entity display objects, so "Entity Display Layout" would be more accurate.
Any objection to calling the experimental module "Entity Display Layout"? Note that this name is just for the experimental phase, it would ideally be subsumed by the Entity Display system and Field UI once stable, there would not be a stable standalone module.
Comment #6
naveenvalecha+1 for the Entity Display Layout b/c that sounds accurate for the layouts
Comment #7
EclipseGc CreditAttribution: EclipseGc at Acquia commentedIs this going to be view mode based? I.E. are we coupling view modes with layouts?
Comment #8
webchickJust... Layout? :) Please? :) Because hopefully eventually this module will be expanded to cover all of Drupal's layout needs?
Comment #9
tim.plunkett#7 It's tied to entity displays, which are indeed per-view mode (an exported config file for an entity view display might be called
core.entity_view_display.node.article.teaser.yml
, for example)#8 That's an interesting thought. On one hand, someone coming to Drupal doesn't care about the distinction between blocks and fields, they just care about Layout. But it's not this module's job to bridge that existing gap.
However, Layout should be something baked into all of core. If I were writing this as a patch, and not as an experimental module, it would just be changes to \Drupal\Core\Entity\EntityDisplayBase and friends, and \Drupal\field_ui.
Comment #10
tim.plunkettTrying to rewrite this to better convey the significance.
Comment #11
eaton CreditAttribution: eaton at Lullabot commentedReally fantastic to see this come together. Even if it ONLY applied to edit forms, it would be a huge benefit — right now we can use field groups to break up the main content area in node forms, but moving tags into the right side along with authoring information (for example) requires squirrelly digging into the intersection of FormAPI and the theme system when it really shouldn't. It'll make a big part of tailoring the authoring experience in Drupal much, much, MUCH smoother.
While it would be awesome to implement a generalized layout management system, exposing a layout per view mode seems like this is a good, high-value first application of the concept. If folks think underlying "entity display layout" plugin type that's being defined could reused (or reused with additions) in other parts of Drupal, I'd say name it "Layout" and treat this as the first implementation.
I think it's valuable enough as is that it should not be held up in hopes of getting a generalized layout system implemented.
EDIT: To clarify, I was talking about the combination of this patch and #2296423, which is a natural iterative improvement on this one.
Comment #12
Crell CreditAttribution: Crell at Platform.sh commentedFirst comment: Aw heck yeah! About time we looked into doing this! Bring it! :-)
My understanding is that the contrib layouts module is sufficiently abstract that it could be used for both view mode layout and other-stuff layout, by design. If the intent here is to use essentially that model but just for view modes, I would agree with Eaton that naming it with the intent that at some point in the undefined future we could/would start using it elsewhere. We don't need to actually use it elsewhere yet in order to make it useful here, just keep an eye toward decoupling it enough that we can later.
A limitation of one view mode gets only one layout is, I think, entirely reasonable at this point and still a epic-sized win over core's status quo today.
TimPlunkett++
Comment #13
swentel CreditAttribution: swentel at eps & kaas commentedIf we'd go for Layout (which I don't mind), what about we (potentially) move #2296423: Implement layout plugin type in core into the experimental module maybe as well. That was the original idea there, but moving it into the experimental would give us more time to flesh out any needs that we need there as well, instead of being 'stuck' as an Plugin manager that's baked into core. I'm close to open an 8.x-3.x branch of DS. If we could depend then on the 'layout' module which alters entity view modes and exposes the layouts, it seems like a really good path forward to experiment with. While that works out fine for DS, I'm not sure if that would work for the Panels ecosphere, that's something that tim and/or dsnopek could answer better.
Comment #14
webchickMoving over to the new Drupal Core Ideas queue while we get this into shape.
Comment #15
mpotter CreditAttribution: mpotter at Phase2 commentedI would love to see this for Form displays. Currently we can use Panelizer for node view modes, but still not for form modes. I think a consistent handling of Layout in core that would work for either of these modes would be really nice to have. Right now it's very difficult to alter the node edit form (putting stuff in the right sidebar), which surprised me.
Comment #16
tim.plunkettComment #17
xjmComment #18
xjmIn the initial step for this plan, #2796173: Add experimental Field Layout module to allow entity view/form modes to switch between layouts, the consensus for the module name is "Field Layout". That communicates exactly what the module does once you know what a field is.
The layout API that Field Layout (and other layouting tools) will depend on was added in #2296423: Implement layout plugin type in core.
Based on the largely positive feedback above, I think this plan is also RTBC enough for at least review of the idea and prototype; both it and the initial prototype in #2796173: Add experimental Field Layout module to allow entity view/form modes to switch between layouts are ready for maintainer review.
Comment #19
xjmAnd adding the tags. I imagine we'll evolve the specifics of the plan as we review the prototype issue, just as we have done with other experimental modules, but we should review them together.
Comment #20
xjmComment #21
xjmComment #22
xjm(Removing redundant tag; this is already in the Ideas queue.)
Comment #23
xjmComment #24
xjmComment #25
xjmThe summary lists these possible next steps from the original post:
Is this #2811179: Allow themes to provide Layout API integration? Probably part of the scope of #2811175: [plan] Add layouts to Drupal, not this plan.
Could?
I think the API added in #2811175: [plan] Add layouts to Drupal could be stable without a new UI, so part of this one probably belongs here scoped as "Front-end UI to change entity layouts". (#2660124: Dynamically build layout icons based on well formed config is, I imagine, only the very first step of this). This is at least a "should". I think we will need product management feedback on whether this is a "must" for this module. @webchick said she considered whether or not we would need a new/better UI to be part of the UX gate for the module (i.e., based on user testing of the alpha module).
Whether or not we offer a somehow unified UI for all implementations is... well, scary. :) But it will depend on what other implementations (if any) we add and support in core, and product manager feedback.
Is this #1787942: Allow assigning layouts to pages? I think it's part of the parent issue, not this one.
Comment #26
webchickWe reviewed this on our Issue Queue Review meeting today.
From a product management POV, the killer feature we are going for here is a "landing page", where you create a page, select a layout, and populate it. However, that is not what we're talking about here. And until we're talking about that (per-node layouts, in a later plan issue), it makes sense for the "could-have" list which contains issues that would expose this functionality to content authors to not be in the "must-have" list.
Nevertheless, this makes for a useful feature on its own for site builders, to be able to set different layouts on a per-content type basis. We are comfortable with the list of must-haves from that POV.
Comment #27
xjmComment #28
xjmComment #29
xjmComment #30
xjmComment #31
xjmComment #32
tim.plunkett#25:
1) Yes, removed from this issue
2) Yes, moved up
3) This was #2820210: Add Settings Tray support to field_layout, but isn't happening anymore with this MVP. Still put a "Could" in mentioning the per-entity overrides
4) No, that needs its own issue. Basically, block placement within Field UI. Moved it to "Could"
Comment #33
tim.plunkettAdding #2844302: Move Field Layout data model and API directly into \Drupal\Core\Entity\EntityDisplayBase as a "Should", if consensus is gathered will move to "Must"
Comment #34
xjmThanks @tim.plunkett! This all looks good to me.
Comment #35
tim.plunkettAdded issues per #2796173-191: Add experimental Field Layout module to allow entity view/form modes to switch between layouts
Comment #36
xjmThe prototype is in, and this is now an active (part of the) initiative also. Great work!
Keeping the FM review tag on for now pending confirmation that this roadmap is correct from that angle as well, though I believe it is based on @effulgentsia's review of the initial prototype.
Comment #37
eaton CreditAttribution: eaton at Lullabot commentedFrom the Layout sprint in Baltimore, a quick summary of the discussions about status of and next steps for this initiative:
If this looks good, I can turn it into a plan/meta issue for the next steps, or update the overview for this one and create some new sub-issues.
Comment #38
xjmSo, trying to parse through #37 and see what might be needed for roadmap updates:
Isn't this already done by Field Layout, or did I miss something specific?
Isn't this also accomplished by Field Layouts already?
This definitely wants its own Ideas issue, I think.
This is terrifying and sounds contrib-y to me.
Let me know if I've misunderstood these things; screenshots of Field Layout showing what it's not doing already might help.
Comment #39
EclipseGc CreditAttribution: EclipseGc at Acquia commentedJust as an FYI, I filed #2874074: Introduce field type that renders arbitrary elements in a selectable layout Saturday after the sprint. Tim and I have been working on functionality and testing, and I think we're at a point where we can begin trying to implement DyanneNova's UI mocks.
Eclipse
Comment #40
eaton CreditAttribution: eaton at Lullabot commentedxjm, you're entirely correct that #1 and #2 are covered by Form Layout and Field Layout — I just hadn't updated those with the correct links before I was felled by DrupalFlu and disappeared. As Eclipse said, #4 is covered by #2874074: Introduce field type that renders arbitrary elements in a selectable layout. I'm catching up on things, but #3 (layout overrides) is IMO a nice-to-have but not required for core as long as the Field Layout mechanism can be hooked into by contrib. Supporting per-bundle/display mode layout control in core is… a radical step forward, to say the least.
Comment #41
tezalsec CreditAttribution: tezalsec commentedHi , sorry to place this here, but couldn't find a better location.
Using Drupal 8.3.4, I tried installing the field_layout module to give it a try, but both installing and uninstalling give me this error:
The website encountered an unexpected error. Please try again later.
TypeError: Argument 1 passed to {closure}() must implement interface Drupal\field_layout\Display\EntityDisplayWithLayoutInterface, instance of Drupal\Core\Entity\Entity\EntityViewDisplay given in {closure}() (line 34 of core/modules/field_layout/field_layout.install).
Now the checkbox says it is installed, but it won't let me uninstall, without the above error.
I should mention I have Display Suite installed as well, is it conflicting?
I wish a clean deinstall of field_layout, what to do? Thanks!
Cheers.
Comment #42
zenimagine CreditAttribution: zenimagine commentedI also display suite to install and I encounter the same problem
Comment #43
Kris77 CreditAttribution: Kris77 commentedI have the same problem....with display suite installed it is not possible to install FIELD LAYOUT module...
Comment #44
tim.plunkettPlease open an issue in the Display Suite issue queue.
Comment #45
tezalsec CreditAttribution: tezalsec commentedissue created: https://www.drupal.org/node/2897810
Comment #46
dqdMeh ... @Maxim75 this is not the right issue. You have hijacked a Display Suite issue, which is about another topic. I will try to tinker and detangle this gallimaufry ...
Comment #47
Alan D. CreditAttribution: Alan D. commentedI think we're going to love this feature. :)
Some (apparently) missing feature in the Field Layout's?
We implemented a very similar system on Drupal 7 as an lightweight alternative to using DS or panels, and these were the core things that could be considered lacking comparing the two.
Region settings
To provide an easy option to add settings to the layout that contrib could expand on, opposed to just the one settings form per layout.
i.e. something similar to the field settings cog exposing the form.
A couple use cases
HTML attribute insertion - classes, id, etc per region.
Bootstrap Layouts - sets element & attributes per region
Nested regions
Appears possible to define and render anything, though via the current field UI above looks flat and sequential.
i.e. Field Groups
Preview screenshot
It's a nice have feature if you start defining heaps of various templates. We worked out that we could effectively use about 12 separate templates to cover most non-landing page layouts.
i.e. Panels icon attribute
Probably moving out of scope, but we also implemented a way to configure the container elements & attributes, entity URL control, plus some bespoke media handling, providing a template based layout system that handled about 98% of the day to day theming requirements. All probably best left for contrib.
Comment #48
andypostDoes it makes sense to file core issue about moving field_layout module to contrib as it does not has beta version?
Comment #49
Gábor Hojtsy@andypost: after consulting @tim.plunkett I opened #3007167: [META] Enable layout builder for form displays, and deprecate field_layout for that.
Comment #50
matthieuscarset CreditAttribution: matthieuscarset as a volunteer commentedIs this idea still relevant/active?
My understanding is that
field_layout
is not needed anymore becauselayout_builder
now provides the expected functionalities.Shouldn't we mark this idea as Closed (won't fix) and remove it from this list?
Comment #51
catch@matthieuscarset layout builder can be configured for view modes, but not for form modes - this is still only handled in core by field_layout. see #3007167: [META] Enable layout builder for form displays, and deprecate field_layout
Comment #52
donquixote CreditAttribution: donquixote as a volunteer commentedI don't like layout builder as a universal replacement for traditional entity displays.
It seems to me that it targets a specific type of user that does not really exist in the projects I work with.
But perhaps I don't see the full picture.
Having field_layout in core is nice, but it being experimental may scare people (including me) from using in production.
The field_layout module (similar to display suite) is also limited in that it only allows one layout per view mode.
An alternative would be to insert layouts into a display, similar to field groups.
Doing this in contrib is always going to be messy. But in core it could work.
We could also make it easier to insert other dynamic elements into a display.
Comment #53
andypost