#2353867: [META] Expose Title and other base fields in Manage Display will introduce the "normal" mechanism for managing display of title and other base fields. In particular #3036862: Expose Title and other base fields in Manage Display in Drupal Core will create a GUI option to enable the normal mechanism.

This purpose of this issue is to deprecate the old specialist non-standard way. At the point of writing, we haven't even invented the new way yet so this issue is planning ahead and guessing somewhat. However it's likely that it would involve

  1. Warning in the status page if the GUI option is still set to the old specialist non-standard way.
  2. Deprecate all the specific items that will be removed in #3015623: [PP-many] Remove outdated code relating to "Expose Title in Manage Display"

We can use the Twig deprecated tag to deprecate templates.

Comments

AdamPS created an issue. See original summary.

adamps’s picture

adamps’s picture

Issue summary: View changes

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

jonathanshaw’s picture

W don't need the GUI option, but we have the entity type setting enable_base_field_custom_preprocess_skipping we have introduced (see change record).

To remind us, the essence of the fix so far is to use a preprocess approach like this:

$skip_custom_preprocessing = $node->getEntityType()->get('enable_base_field_custom_preprocess_skipping');
if (!$skip_custom_preprocessing || !$node->getFieldDefinition('title')->isDisplayConfigurable('view')) {
  // Some custom preprocess logic than ignores configured field display.
  $variables['label'] = $variables['elements']['title'];
  unset($variables['elements']['title']);
}

The essence of this is that preprocessing is skipped only if a flag is set AND isDisplayConfigurable is set (neither of which are set by default currently).

A deprecation strategy was proposed by @plach in [#2923701-283):

  1. [Introduce a] flag ... enable_base_field_custom_preprocess_skipping
  2. ...introduce a check on FieldDefinitionInterface::isDisplayConfigurable() for each entity field. ...
  3. Once all core entity types got this treatment, deprecate the enable_base_field_custom_preprocess_skipping flag.
  4. Verify whether the current core behavior can be implemented via layout builder (+ maybe custom formatters?) and:
    if at all possible, use that instead of the custom preprocess logic when the flag is enabled; this would make core default's behavior match the current one, but would allow people to configure base field display via the UI;
    if it's not possible to conditionally enable the LB configuration, just deprecate the preprocess logic and suggest to use Layout Builder instead.
  5. In D9 remove the flag and the custom preprocess logic, leave only the Layout Builder configuration as default.

Our normal deprecation strategy would be to use @trigger_error($message, E_USER_DEPRECATED) whenever custom preprocessing happens.

adamps’s picture

I believe this issue will be extremely simple: we will add a trigger_error to all the branches of code that we intend to remove. The complexity comes in the other issues.

1. & 2. Already done.

3. Is the only part that relates to this issue. Basically I agree, however the description at the top of this comment is more precise.

4. Is a comment relating to #3033301: Add formatters and other mechanisms as alternative to base fields directly in entity templates, suggesting to use layout builder and it would be useful if you post it there.

5. Is #3015623: [PP-many] Remove outdated code relating to "Expose Title in Manage Display"

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

anna d’s picture

Any ideas on continuing work on this issue?

I found that a user:id (node author) cache tag is added to every node. However, the author display is disabled, and a small investigation led me to template_preprocess_node().

By default this function performs special preprocessing of some base fields so they are available as variables in the template. For example 'title' appears as 'label'. This preprocessing is skipped if:
a module makes the field's display configurable via the field UI by means of BaseFieldDefinition::setDisplayConfigurable() AND the additional entity type property 'enable_base_field_custom_preprocess_skipping' has been set using hook_entity_type_build().

This is unclear to me because $submitted_configurable is FALSE in my case (the date and UID fields are not displayed in the view display). As a result, the condition if (!$skip_custom_preprocessing || !$submitted_configurable) is always TRUE.

Additionally, I would separate the date and UID in this case. If only the date is needed, the author (and consequently, the user cache tags) is still added.

catch’s picture

That comment suggests that $submitted_configurable needs to be TRUE in order for that logic to be skipped, that might be the specific problem you're seeing?

I think we need to add a 'computed' (extra) field for 'submitted', once we have that, we can deprecate adding it directly in templates.

Adding another related issue.

anna d’s picture

Yes, and this is not clear to me.

$submitted_configurable = $node->getFieldDefinition('created')->isDisplayConfigurable('view') || $node->getFieldDefinition('uid')->isDisplayConfigurable('view');

The Created On (date) and Created By (uid) fields are not configured to be displayed. However, I need to display them in order to avoid adding a related author cache tag. Is that correct?

catch’s picture

You need to alter the field definitions to allow them to be displayed (or install the manage fields module which does this), they don't actually need to be displayed.

All of this logic is in desperate need of updating but several of the issues around it are stalled.

adamps’s picture

All of this logic is in desperate need of updating but several of the issues around it are stalled.

Unfortunately yes😃. #3470497: Add a tag select list in string Formatter is the likely next step, and it was moving well. But now the next step is a quite complex update hook.

@catch is there any chance of any funding being available? It probably wouldn't take a huge number of hours to make real progress on the whole META area. Unfortunately it's often too much to do for free.

catch’s picture

@adamps there is still no way to get direct funding for core development except via individual employers.

The two routes I can think of would be:

1. If there's a demonstrated need for Drupal CMS, then a company might sponsor work via the starshot contribution credits system.

2.Experience Builder must need to control where 'submitted' gets placed in an entity layout at some point, possibly before it can have a stable release, so will hit this problem soon. Likely the same for the title.

Even if not funding, those would be two potential ways to get extra reviewers.

For me personally I think that 'submitted' would be the best place to focus short term efforts rather than title (which I assume #3470497: Add a tag select list in string Formatter is blocking) because it is a bit more self-contained.

adamps’s picture

Thanks @catch. Let's hope that someone needs this issue enough to be willing to fund it.

The sequence of events as I understand it is described in #2353867: [META] Expose Title and other base fields in Manage Display.

It proposes we next work on phase B stage 1 which is covered by issue #3033301: Add formatters and other mechanisms as alternative to base fields directly in entity templates. That will involve #3470497: Add a tag select list in string Formatter as the solution for 'title', and it seems quite close to completion. The equivalent for 'submitted' is more complex, however working code does exists in "Manage Display" contrib; it doesn't have its own Core issue yet as far as I know.

ressa’s picture

Thanks so much for working on this, having "Title", "Authored on", etc. directly available under Display would be such a great feature.

We could consider adding a new header "Funding" in the Issue Summary of important Drupal core issues such as #2353867: [META] Expose Title and other base fields in Manage Display, with a text like this?

Funding

Drupal relies on the community for resources, and the Drupal core developers working on this task are looking for funding. Please contact @developerA or @developerB for further details on timeline and budget.

The companies who sponsors the completion of this task will be listed as sponsors of this feature in the Issue Summary, as well as on drupal.org/issue-sponsors/display-title and receive eternal gratitude from the Drupal community.

It has previously been seen to work, to gently make the users aware, that this great software needs real humans to spend time building it, for example in #3247389: Plan for stable release.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.