Don't force two column layout on default display mode when Layout Builder is enabled

Created on 19 October 2021, over 3 years ago
Updated 30 October 2023, over 1 year ago

Problem/Motivation

Recently we implemented some hooks in farm_ui_theme to use a stacked two column layout for the default full view mode of assets, logs and plans: https://github.com/farmOS/farmOS/commit/98aa8b5ee0030e4fb90694187d801d99...

Combined with hook_farm_ui_theme_region_items this makes it possible for contrib modules to define which region to place different fields in: https://github.com/farmOS/farmOS/commit/c6112ff7f69bef0c68f80c9a80e4e32d...

A side effect of this is that using the core field_ui module to modify the default display mode (I guess this is technically called the full mode in theme hooks?) becomes limited. Fields can still be rearranged and hidden from the display, but not moved from one region to another.

More importantly if the display mode is configured to use layout builder, the custom layout will always be rendered in the left of the two column layout farm_ui_theme sets. It would be great if this default two-column layout could be overwritten by updating the default view mode via field_ui.

@pcambra and I talked about this a bit today. In the farm_nfa project he implemented a workaround that simply removes the relevant farm_ui_theme preprocess function: https://github.com/mstenta/farm_nfa/blob/98ba2df1040c086c01ef7e1eb99f466...

Ideally these default view modes could be configured with a two column layout using layout builder itself. The challenge is that this might mean committing the default display modes, and up to this point we've avoided committing default display modes!

Steps to reproduce

Configure layout builder on asset/log/plan default display mode.

Proposed resolution

@pcambra had a couple related ideas.... what if we had a custom block or "managed layout" that was responsible for rendering the "farmOS default display" and invoking hook_farm_ui_theme_region_items to render fields in the configured regions?

This way we could commit a default display mode that would only have a couple things configured: it would use layout builder and specify the custom block and/or layout to use. The rest of the rendering magic would happen programmatically, unless the default display mode was configured to NOT use this block or layout. It seems like this could work pretty well and be fairly easy to implement.

The distinction between a custom block vs layout is interesting... a block feels like this would be more "reusable" (and potentially configurable as well!). But a custom layout would require hard-coding more of this logic to whenever the layout itself is used. Having this layout as an option in layout builder could be a little confusing as well.

Remaining tasks

Decide if a custom block or layout, or another approach, might make this possible.

User interface changes

Default display mode can be configured as expected in field_ui.

API changes

None - or maybe renaming/slight changes to hook_farm_ui_theme_region_items?

Data model changes

None.

✨ Feature request
Status

Needs review

Version

3.0

Component

User interface

Created by

πŸ‡ΊπŸ‡ΈUnited States paul121 Spokane, WA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024