Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 295308

Expose Title and other base fields in Manage Display in Drupal Core

$
0
0

This issue has been split off from #2353867: [META] Expose Title and other base fields in Manage Display as one of the steps in the overall process. Specifically this issue covers enabling the fields in Manage Display settings, following on from the work of #3033301: Add formatters and other mechanisms as alternative to base fields directly in entity templates which created the necessary formatters.

This applies to base fields that are displayed with setDisplayOptions() but are not configurable with setDisplayConfigurable - instead they are hard-coded into the field template with custom preprocessing. The full list of fields can be found by searching the code for the flag enable_base_field_custom_preprocess_skipping.

Proposed resolution

Update the base field definitions. We can use the node title field as an example, see Node::baseFieldDefinitions().

The current base field definitions are:

  • type = string
  • display configurable = FALSE
  • extra preprocessing in template_preprocess_node() = TRUE
  • special inline display in node_preprocess_field__node() = TRUE

The new base field definitions are:

  • type = title (new formatter created as part of #3033301)
  • display configurable = TRUE
  • extra preprocessing in template_preprocess_node() = FALSE
  • special inline display in node_preprocess_field__node() = FALSE

In addition to the base field definitions, the GUI setting would also trigger the following changes:

  • The node content type setting "Display author and date information" no longer exists
  • The theme settings for user picture are removed
  • The user name field becomes a label

Transition/migration/deprecation

Proposal is a GUI setting that enables this feature, switching from the old base field definitions to the new ones. As part of #3015623: Remove outdated code relating to "Expose Title in Manage Display" we propose to deprecate, and eventually delete the extra preprocessing. At this point, the GUI option would be removed, and the new base field definitions would always be used.

Other options are likely not acceptable for BC:

1. If we enable isDisplayConfigurable() but do nothing else then the result is basically worse than useless because we expose the problems in #2923701: Mechanism to disable preprocessing of node base fields so they can be configured via the field UI - trying to use the Manage Display GUI has no effect except perhaps to generate broken markup. It would not help at all to change the theme or the templates. The only fix is to disable the extra pre-processing which requires custom code.

2. If we in addition disable the extra pre-processing then it's even worse. The Manage Display GUI will now work. However the display settings for each field will be very wrong, and it will be complex and time-consuming to resolve.

3. If we write the entirety of the code in the IS, but without any GUI setting then it's getting better. The display settings for each field will now be set to sensible defaults. However if a site has customised their node template then the results of that will be lost. Some node.html.twig template variables will not be set: label, date, author_name, display_submitted, author_picture, author_attributes. This is the closest I can see without a GUI setting, but I am doubtful the BC rules allow deleting of template variables.


Viewing all articles
Browse latest Browse all 295308

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>