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

Field rendering should respect configurable field display

$
0
0

Problem

As discussed in #2353867: Title does not appear as a field in Manage Display, sitebuilders cannot configure the display of node's title even though they often want to.

Worse, even if developers use a hook to modify the node's title field adding ->setDisplayConfigurable('view', TRUE), and a sitebuilder then enables the title field in a view mode, it makes no difference. The template_preprocess_node and the node.html.twig take over the rendering of the node's title, ignoring the configured view displays.

The same problem applies to node 'created', node 'uid', taxonomy term 'name' and aggregator feed 'title' fields.

This issue has been split from #2353867: Title does not appear as a field in Manage Display to contain minimal, fully back-compatible changes to core in order to allow setDisplayConfigurable to be usable in contrib. The changes here are also a necessary prerequisite to solving the original issue in core.

Solution

1) Modify the logic of template_preprocess_* and templates so that they only usurp rendering if the field's display is not configurable.

2) The template field--node--title.html.twig overrides the normal field template with special case handling for the usurped node title (and similar for uid and created). Fix this so that the special handling only occurs as appropriate, by means of a general '#inline_field' setting on the field template.

Results

If a developer makes these fields configurable, then a sitebuilder can configure them and the configuration will take effect except when the entity is viewed on it's "own page" (in particular at its canonical route as the main display or potentially other cases such as the preview page). In that situation, there are a variety of problems related to EntityViewController's buildTitle method which are covered in #2941208: Title formatting broken due to flawed EntityViewController->buildTitle.


Viewing all articles
Browse latest Browse all 294802

Trending Articles



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