Enable the field interface for creating fields and view modes on content menu items

Created on 10 April 2019, over 5 years ago
Updated 14 March 2023, over 1 year ago

What is the problem to solve?

Currently, when you create custom menu items only the fields provided by core appear in the form with a fixed arrangment.
Since these links are a content entity they are technically fieldable but field_ui and the entity definition do not enable this possibility.

Proposed resolution

This proposal aims to add the code necessary to show the field UI interface and modify the menu theme template so it shows the rendered menu item content when available.

Since adding new view modes will be possible it also makes sense to be able to use them and the best place would be a view mode selector for the system menu block for choosing how the elements are going to be rendered.

Who is this for?

This solution will be focused mainly on site builder needs so they can add fields, manage their display and the form for adding new links.

Result: what will be the outcome?

With this ability enabled in core we can deal with popular use cases like adding icons to menu items.
This will open the possibility to have more features around the menu system like different view modes to create what is known as 'megamenus' but this initial proposal will try to have minimal impact on how the menus work.

How can we know the desired result is achieved?

There is already a module that demonstrates the functionality: Menu item content fields .
Another alternative approach is implemented by https://www.drupal.org/project/menu_item_extras

I found an issue that needs to be fixed so we don't add workarounds to the field UI module.
📌 Custom menu link entity type should not declare "bundle" entity key Needs work

The initial suggestion to propose this as an idea comes from the following issue
Introduce MenuLinkContent bundles Closed: won't fix .
In general there is some issues that propose bringing back bundles to menu entities(they existed at one point of the Drupal 8 development cycle) but I think first bringing fields and view modes will solve a lot of use cases like it does for the user entity and bundles can be considered in the future.

Screenshots

The most sensible place to place the tabs will be under /admin/structure/menu as tabs

Adding an image icon field to the entity

Sorting the form so the icon is the first thing we see (as it will appear first in the menu display)

We can configure the display of the icon

and then create some menu items with icon

Place the menu block

And then it will display like this (some CSS applied for the screenshot)

We can also add new view modes

Feature request
Status

Needs review

Component

Idea

Created by

🇪🇸Spain rodrigoaguilera Barcelona

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