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: [PP-many] 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.

CommentFileSizeAuthor
#10 Manage-display-node.png152.43 KBvacho
#10 3036862-10.patch1.19 KBvacho

Issue fork drupal-3036862

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

AdamPS created an issue. See original summary.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

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

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

adamps’s picture

Title: Expose Title and other base fields in Manage Display in Drupal Core » GUI option to expose Title and other base fields in Manage Display in Drupal Core

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.

andypost’s picture

Looks it depends on related

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.

vacho’s picture

StatusFileSize
new1.19 KB
new152.43 KB

This patch is a starter point to start a code patch that fix this requiremient. The patch let to the user get title field for display configuration:

node display

Still needs works on:

1. Apply patches for this related-blocked issues to test with it:
- https://www.drupal.org/project/drupal/issues/2993647

2. Review this knowed problems/cases:
- Whats happen if the user hide/disable the title? => validate
- Review core/lib/Drupal/Core/Entity/Controller/EntityViewController::buildTitle() compatibility

3. Review node.html.twig to make title field dinamic. Review also the code field--node--title.html.twig

4. Review that no break funcionality for layout_builder module.

5. Review if fix the problems and share knows with another solutions like contrib modules manage_display, title, ...

more issues can appear and needs to fix.

vacho’s picture

...

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

Status: Active » Closed (outdated)

#10 is out of scope for this issue in the context of the roadmap #2353867: [META] Expose Title and other base fields in Manage Display.

Regarding the intended purpose of this issue in the context of the roadmap:
I do not believe we should do this anymore. Let's go direct to always setting setDisplayConfigurable(TRUE). We don't need an intermediate GUI option that we will to deprecate/remove shortly anyway. The proposed solution here would make sense only if core development had a much faster velocity than earlier experience in this family of issues shows that it does.

Let's close this issue.

adamps’s picture

Status: Closed (outdated) » Active

@jonathanshaw Let's discuss this idea before changing the status and summaries of all the related issues.

Perhaps I didn't grasp your proposal, however at first glance it seems to break the rules for Core BC

adamps’s picture

See comment for explanation.

adamps’s picture

Title: GUI option to expose Title and other base fields in Manage Display in Drupal Core » Expose Title and other base fields in Manage Display in Drupal Core
Issue summary: View changes
catch’s picture

It's not possible to commit a fix that simply enables this feature automatically as it could break backward compatibility. When the new base field definitions are enabled, the site owner needs to examine and possibly correct their field display settings.

As long as the new fields are only available in display mode configuration, and somehow aren't forced to show on nodes by default, then I don't see how this would break bc or require additional configuration options other than display mode - it'd just be an additional option in manage display.

adamps’s picture

Thanks @catch. However I've thought so more and I'm pretty sure that it's impossible for this to be automatically enabled and still BC.

Imagine that a site edited node.html.twig as follows.

  1. Change "Submitted by UUU on DDD" to "DDD: another cool article by UUU"
  2. Moved the author picture after this sentence instead of before and wrap it in a div with some custom classes
  3. Move the title after the author picture and use <h3> not <h2>.

How could we possibly even imagine an automatic migration process that would parse every single instance of node.html.twig on the site and create the exact same output using field formatters? So if we automatically enable manage display on this site, then there are two possibilities:

  1. We lose the above customisation, reverting to the default title/submitted = big BC break
  2. We keep the above customisation, in which case the site admin is able to move the title/author/created around in manage display but it's totally broken - it has no effect or generates bad markup.

Therefore if we are going to remove the extra preprocessing and move to field formatters (which is obviously desirable), there will be a cost:

  1. We need a GUI setting to enable.
  2. Every site and every theme that has customised title/submitted in node.html.twig will have to re-apply their customisation in a different way before they can upgrade to D11.

Would be useful to have thoughts on the acceptability of this cost.

catch’s picture

We keep the above customisation, in which case the site admin is able to move the title/author/created around in manage display but it's totally broken - it has no effect or generates bad markup.

Right but there are lots of things you can do in manage display that don't actually look very good. It's not really different to adding a new field formatter that's incompatible with a custom or theme preprocess (which happened to me today).

In that case, the site owner would have to install a different theme, or if it's a custom theme, handle the fields differently in the template, and then update the configuration and theme at the same time.

Every site and every theme that has customised title/submitted in node.html.twig will have to re-apply their customisation in a different way before they can upgrade to D11.

Yes exactly, but the advantage is that they won't have to handle these fields in node.html.twig ever again, and can do everything in formatters/field templates/manage display from then on.

xmacinfo’s picture

I don’t expect a theme working fine in Drupal 10 to work without any change in Drupal 11.

Contributed themes will most probably update their Drupal 10 themes to support the new markup for Drupal 11. Although we want the core changes to be minimal.

Custom Drupal 10 themes will definitely need to be fixed to work in Drupal 11, but usually, we would permit the Drupal 10 theme to be loaded in Drupal 11, at the cost of some variables not loading. So it would be easier to change some twig code and debug the Drupal 10 theme directly in Drupal 11. And at that point, the theme does not have any version constraint, Drupal 11 just needs to highlight an error in Watchdog when something is not updated yet to support Drupal 11.

In change records, we could document the old vs the new way to represent a value, use the Title field, etc.

Same thing for field formatters. It is perfectly fine when updating to a major version, to review field formatters and reapply those. Although here, we try to be BC as much as possible.

xmacinfo’s picture

I think we should switch the version of this ticket to 10.0.x-dev, though.

adamps’s picture

Version: 9.4.x-dev » 10.0.x-dev
Issue summary: View changes

Thanks @catch and @xmacinfo for continuing the discussion.

I don’t expect a theme working fine in Drupal 10 to work without any change in Drupal 11.

OK, good so it seems that we are in agreement on that.

In summary, this issue causes a modest migration step, but it seems fine with the normal deprecation mechanism so sites have a whole major release to do it.

On the other hand if we force people to do the migration step in a minor release (and possibly they don't realise the non-BC problem until they can no longer roll back) I feel it would not be welcomed.

The GUI option is not so difficult to write.

Right but there are lots of things you can do in manage display that don't actually look very good. It's not really different to adding a new field formatter that's incompatible with a custom or theme preprocess (which happened to me today).

As far as I can see it's unfortunately much more disruptive than that. I updated the IS with a list of options that I can imagine without a GUI setting. Number 3 is the best one, but even that I doubt is allowed in a minor release because it deletes template variables and loses customisations. Can anyone confirm/clarify on this?

I think we should switch the version of this ticket to 10.0.x-dev, though.

Good idea, done.

catch’s picture

The node content type setting "Display author and date information" no longer exists

For this I think we're going to need multiple approaches:

1. An 'extra field' which reproduces the current format (By [username] on [date]) so that it's easy for sites to recreate the current look with the new API (also convenient for new sites too in some cases).
2. Also the ability to show the individual fields with standard formatter settings.

I'm looking at the logic we added around custom preprocessing:

field--node--uid.html.twig
{% if not is_inline %}
  {% include "field.html.twig" %}
{% else %}
<span{{ attributes }}>
  {%- for item in items -%}
    {{ item.content }}
  {%- endfor -%}
</span>
{% endif %}

And I'm wondering if we could dynamically set is_line based on the display configuration i.e. if the display configuration contains the uid field, then set is_line to false, or alternatively base it on the 'display submitted' configuration option (which we'd then start triggering a deprecation message when that is set in preparation to remove the setting).

That would mean it wouldn't be possible to use both the submitted variable and also have the fields via manage display in a way that would work, but don't think we need to support that and we could even add validation for that case.

adamps’s picture

For this I think we're going to need multiple approaches:

That makes sense, I agree.

The SubmittedFormatter in Manage Display module replicates the current format exactly. If we want to discuss the benefits of that compared with extra fields, we should likely do it in #3033301: Add formatters and other mechanisms as alternative to base fields directly in entity templates.

And I'm wondering if we could dynamically set is_line based on the display configuration

In node_preprocess_field__node() we already set 'is_inline' dynamically based on enable_base_field_custom_preprocess_skipping and isDisplayConfigurable. This code already works in 3 cases:

  • SubmittedFormatter
  • Show fields separately with existing formatters
  • Sites still using the extra custom preprocessing.

My expectation is that the is_inline variable and these special base field templates like field--node--uid.html.twig can be deprecated and eventually deleted. They are another part of the 'magic hackery'. We should have a mechanism to display "Submitted by" that works for any entity type including comment and media in core. It's not attractive to add the same magic hackery (quite complex!) to every similar entity type.

That would mean it wouldn't be possible to use both the submitted variable and also have the fields via manage display in a way that would work, but don't think we need to support that and we could even add validation for that case.

Absolutely, I agree, the two possibilities are fundamentally incompatible. Manage Display GUI of the base fields only works if enable_base_field_custom_preprocess_skipping is set, in which case the submitted variable is not set.

jonathanshaw’s picture

Thanks for your detailed replies @AdamPS, and thanks for staying with us @catch. These are really hard things to figure out, so your persistence is invaluable.

I'm going to take up Adam's invitation to follow up the discussion from #2353867: [META] Expose Title and other base fields in Manage Display here.

@adamps #121 I think that people potentially don't fully understand the complexity of the changes needed here. The file manage_display.module contains 170 lines of code that are needed to do this.

The complexities are indeed intricate, and you've led the way in figuring them out. I've reviewed manage_display.module, and spent several hours carefully considering BC strategies here. I'm not sure I'm right, but I am sure these things are complex enough to require
careful discussion.

Strategy B

In #118 Strategy B (safer) I proposed this:

1. In 9.4 deprecate having the base field ->isDisplayConfigurable(TRUE) without using enable_base_field_custom_preprocess_skipping.

2. In 10.x
a. set isDisplayConfigurable(TRUE) on the base fields
b. skip preprocessing if EITHER enable_base_field_custom_preprocess_skipping is set OR (field is ->isDisplayConfigurable(TRUE) AND field is a child element (i.e. has been explicitly configured to be visible).

In #121 @adamps responded:

Point 2a suggests to set isDisplayConfigurable(TRUE). This would turn off the custom preprocessing, however it would not enable anything else to replace it. The title would show as plain text rather than a heading and link. ... Fields that were previously hidden would suddenly become visible. Any site that has not updated their templates as recommended in recent change records (which is entirely legitimate) would suffer further problems. So suddenly everyone's sites are totally broken.

I believe this is all untrue, because of the implications of points B1 and B2.b. Let me explain (which is also repeating @catch's points from #17/#19 above):

Any site that has not updated their templates as recommended in recent change records (which is entirely legitimate) would suffer further problems.

I'm not sure what problems you have in mind, but my purpose in suggesting doing B1 first in 9.4 is to make sure that everyone who has enabled isDisplayConfigurable() has also updated their templates. (unless they are ignoring our runtime deprecation errors, in which case they are on their own; this is how core handles BC).

Point 2a suggests to set isDisplayConfigurable(TRUE). This would turn off the custom preprocessing, however it would not enable anything else to replace it. The title would show as plain text rather than a heading and link.

By implementing B1 and B2b, this does not happen. Now that B1 ensures enable_base_field_custom_preprocess_skipping is set on sites where isDisplayConfigurable(TRUE) has been previously set, there are 3 scenarios we find existings sites in:
i. (isDisplayConfigurable was & is true AND field configured to be visible) => preprocessing was & is skipped, field was & is shown normally
ii. isDisplayConfigurable was & is true AND field is configured to be hidden) => preprocessing was & is skipped, field not shown normally or from preprocess
iii. (isDisplayConfigurable was false now true, AND field was not configured is now configured hidden) => preprocessing was not & is not
skipped, field not shown normally but shown via template hardcoding; preprocessing will be skipped and field shown normally not via template hardcoding when the field is configured to not be hidden.

There is one disadvantage to this approach: the manage display UI will not allow sitebuilders to hide a base field if they are using the core templates. If they move a base field into the 'hidden' region (or leave it in there when it's first made configurable), it will still show up in the rendered output because of the preprocess & template hardcoding. This could be a little head-scratching, though may be not more of a WTF than having non-configurable base fields in the first place. The only way to really hide the title would be to set enable_base_field_custom_preprocess_skipping in custom code or customise the template.

Configuration setting

You've proposed a "Gui setting". I'm assuming this is configuration with a UI. The UI is not strictly relevant to BC, we could maybe have configuration without it.

If we go this way, I think we should default the setting to FALSE, both for existing sites and new installs. The reason fot this is as in #118 with regard to strategy B:
it avoids us having us to wait on developing a 100% perfect drop-in reimplementation of the existing experience in #3033301: Add formatters and other mechanisms as alternative to base fields directly in entity templates. This will be hard to, and would force us to perpetuate legacy aspects of the current base field display.

For example, it configurable base fields are purely opt-in, keeping the existing template behavior as the fallback if people don't opt-in, then we don't need to provide a replacement for "Display author and date information" if we don't believe it should be part of Drupal core. People who really want that exact display of authoring info can get it from contrib or custom. And best of all, this whole debate can be allowed to take as long as it likes. We push on with making it easier to customise core (the framework), without having to decide first exactly which options core (the product) should provide.

I think this issue should not be blocked by #3033301: Add formatters and other mechanisms as alternative to base fields directly in entity templates.

Strategy B vs a configuration setting defaulted to false

Both these solutions are undisruptive to existing sites, they're a 100% BC within the scope if this issue.

The hard question is about how they set things up for the final removal of the preprocess variables in future issues for anyone using custom templates.

We can definitely throw a deprecation error in core twig template if a preprocess variable is used, so that gives us a solid coverage for anyone using core templates. It's custom templates that are tricky.

There's various ways of thinking about this.

1. Hardline. @catch said in the meta in #122:

we don't provide bc for render arrays, or non-classy/stable templates, see https://www.drupal.org/about/core/policies/core-change-policies/drupal-8...

And I seem to remember @lauriii saying something to the effect of "if a template depends on a variable, you should implement a preprocess to ensure the presence of that variable, we can't guarantee it"

2. Major. @catch again in #122 implies that we can do things in a major that we can't in a minor; given they are not covered by BC policy dropping templates variables in a major is OK in theory. But inn practice all these questions are addressed pragmatically based on likely disruption.

3. @catch suggested phpstan. phpstan-deprecation-rules allows emits deprecation warnings on code, which uses properties/functions/methods/classes which are annotated as @deprecated. I don't see how this helps us.

4. The usual core approach is @trigger_error(..., E_USER_DEPRECATED). It's tricky here because the logic path to set the variables in preprocess is harmless, it's using them in a template that we want to deprecate. If we @trigger_error in the preprocess, we cause a deprecation error for sites that that may not need to do anything. We can tell them to either ignore the deprecation error (if not using custom templates or if they want the basefield hidden) or set enable_base_field_custom_preprocess_skipping to silence it.

5. The configuration and UI option proposed in the IS would allow us to trigger a deprecation error on any site that has not opted in to the configuration, telling them they now have to do so (or ignore the error if not using custom templates or if they want the basefield hidden).

So in BC terms the configuration setting turns out to be identical to my strategy B, just more complex to implement and later remove.

Am I seeing this right?

catch’s picture

3. @catch suggested phpstan. phpstan-deprecation-rules allows emits deprecation warnings on code, which uses properties/functions/methods/classes which are annotated as @deprecated. I don't see how this helps us.

It'd have to be a custom rule looking for particular variable usage in templates.

adamps’s picture

Many thanks @jonathanshaw for putting in so much time and energy even after my reply in the other issue was a bit negative. I haven't fully grasped all that you say. However I believe I have understood it enough to make some initial comments.

It might be the case that we each of us need to write some patches. I believe I can entirely imagine that patch I would write - indeed it is quite simply a case of transferring some code from Manage Display into Core. Perhaps I should write it first without the config setting. This would stand as a candidate solution for where we IMO are ultimately aiming for.

I don't yet understand how you would achieve some parts of the IS proposed resolution in your solution B.

1. The IS describes 'current' and 'new' base field definitions. How would you achieve the updating of the default type in Node::baseFieldDefinitions()? The current definitions seem highly unsuitable for use when base fields are present in Manage Display, so we need a strategy to change them. Arguably this is the key part of the whole BC debate, because there is no halfway option - somehow we need to make a change that's inherently not easily BC.

2. The IS says: "the GUI setting would also trigger the following changes:...". If there's no config option we would also need another way to achieve these parts.

I'm not sure what problems you have in mind, but my purpose in suggesting doing B1 first in 9.4 is to make sure that everyone who has enabled isDisplayConfigurable() has also updated their templates.

I believe we are too late for that. It seems that anything deprecated in D9.4 would not get removed until D11. I haven't seen this written down but that was what @larowlan said related to a different issue.

b. skip preprocessing if EITHER enable_base_field_custom_preprocess_skipping is set OR (field is ->isDisplayConfigurable(TRUE) AND field is a child element (i.e. has been explicitly configured to be visible).

NB the title, UID and created fields are currently visible by default so I don't see how to write code for your concept "explicitly configured to be visible". As soon as someone saves their display settings, config will be saved for the newly visible base field. If the admin didn't explicitly change them, then the defaults will be saved. So I am speculating that the admin makes a minor adjustment to any field display and suddenly their title and submitted display switches to all the "disastrous" scenarios I described earlier.

You've proposed a "Gui setting" ... If we go this way, I think we should default the setting to FALSE, both for existing sites and new installs.

I agree.

it avoids us having us to wait on developing a 100% perfect drop-in reimplementation of the existing experience

I agree it doesn't have to be a 100% identical replacement, however I feel it does have to be something 100% suitable and at least as good.

One of the key objectives is to deprecate and eventually remove the extra preprocessing. Before we do that, we would need something to replace it. I feel at minimum we need a title formatter, and some sort of solution for submitted information - these seem absolutely fundamental aspects of a CMS that should be in Core not Contrib.

I think this issue should not be blocked by #3033301: Add formatters and other mechanisms as alternative to base fields directly in entity templates

I think the issue as currently described is inevitably blocked because it proposes to update the type of a base field definition to something that doesn't yet exist. Possibly we could unblock it by reducing the scope here. However we should still make sure we know how to solve the entire problem eventually.

adamps’s picture

In summary, I agree it would be clearly advantageous to avoid a config setting, so it's a really good idea to explore that. On the other hand, a config setting is not really such a big problem. I am concerned that the alternative might actually create more problems - in the worst case could be fragile, confusing, and prolong the 'agony' of the current confusion multiple stages as we incrementally solve the problem.

Is there really any urgency to press us to make partial solutions? We've made really good progress so far and sites that want manage display can now get it - with some simple hooks, or using the contrib module "Manage Display".

Before insisting that the whole Drupal community adopt our initiative I feel we should ensure that we are offering something they will welcome, rather than dislike.

adamps’s picture

OK here's another way to look at it.

I have a proposal the create a new setting for Manage Display of base fields. This makes is very clear to people that they have a choice to make and what the implications are.

You are proposing to guess or deduce people's preference based on other settings. This could work, however I am rather doubtful. For example suppose someone hides the title field because they don't want it displayed. This would apparently alter your algorithm and re-enable extra preprocessing meaning the title field actually is displayed based on node.html.twig.

I have probably spent over 100 hours working on this area. I've tried lots of different things in code and my proposal is based on the best option I've found. I think you to explore your ideas further would be greatly assisted by showing a working patch. So many ideas that seem good in theory don't work out as expected when you try to implement them😃. I would very much welcome another developer to share the work and bring new ideas.

adamps’s picture

OK here's a new brain-storming idea

We create a new setting in manage display for the base fields: "Use node template", which means enable special preprocessing. This is used as the default for the base fields at least for all existing sites. However it is deprecated and later will be deleted.

jonathanshaw’s picture

You're right, code speaks 1000 words. Some of your concerns above are clearly sensible, some might be misunderstandings of what I did not express well.

So here's what I mean in code, as it applies to the node title, in 4 steps (6 commits of which 2 could have been combined with predecessor).

Can you say in a nutshell what your outstanding concerns are now you see this?

adamps’s picture

Before we dive into more detail, I'd like to take a step back.

I have proposed a strategy:

  • It has been available for discussion for 1-2 years.
  • It has been tested out thoroughly with a contrib module Manage Display that has 1600 sites using it.
  • The migration has been designed to be highly safe and BC: sites can choose when to adopt and can go back.
  • We are starting to build momentum and support from core committers.
  • The remaining work is mostly to transfer code from Manage Display that has been well tested.
  • We can reasonably expect to have a working solution in D10 and remove old code in D11.

You have proposed a strategy:

  • It has arrived just now, quite late in the initiative.
  • It is only an idea with an untested code fragment. FYI your MR seems totally broken to me.
  • The migration (IMO) is potentially risky and confusing: sites are forced to adopt and can't go back; the new UI is potentially confusing with unexpected effects that could break sites. I'm not convinced of your claim it's 100% BC.
  • You apparently only solve part of the problem described in this issue.
  • I've already spent approx 5 hours discussing it with you and you likely spent the same. With those 10 hours we could possibly have written a patch to add the TitleFormatter to Core.

Can you say in a nutshell what your outstanding concerns are now you see this?

First of all please can you explain your concerns with the established proposal😃.

jonathanshaw’s picture

I've created #3270148: Provide a mechanism for deprecation of variables used in twig templates with a working patch that allows us to trigger deprecation errors when deprecated render array keys are used in twig templates. It doesn't help with the rarer cases where they might be used in downstream callbacks or preprocess hooks, but it should substantially reduce the disruption of removing render array keys.

please can you explain your concerns with the established proposal

1. The config setting is an extra complication that might become controversial. This is a pretty minor consideration.

2. Whether we use the config or not, I don't see we have to wait on #3033301: Add formatters and other mechanisms as alternative to base fields directly in entity templates before we set isDispayConfigurable(TRUE).

The MR has the wrong target, but the individual commits are fine and should clarify why I think this.

I'm happy to bow out of the discussion at this point, as you say I'm taking up more of your time than I'm saving.

adamps’s picture

I'm happy to bow out of the discussion at this point, as you say I'm taking up more of your time than I'm saving.

No I'm not trying to shut you out, rather I'm saying please let's be focused. I'm out of time for speculative discussion. There are two approaches that seem productive:

  1. clear specific comments/questions
  2. working patches that can be evaluated.

The MR has the wrong target, but the individual commits are fine and should clarify why I think this.

I'm afraid that they don't for me😃. If you can provide a valid patch for D9.4 that covers all 3 node fields then I am happy to test and discuss. The strategy and patches I am proposing are not perfect but are the best I've managed to get to work. It's easy to bring another solution and say that in a certain aspect it is better. However the alternative solution isn't much use if it fundamentally breaks another aspect. I don't currently see the seed of a working solution in the MR. However I would encourage you to continue to work on it and see if you can bring one out.

I don't see we have to wait on #3033301

I.e. you propose some intermediate state - we would set isDispayConfigurable(TRUE) first and then the other changes from the IS in a separate issue. Your MR even suggests a series of 4 separate commits/issues. In response I would ask

  • It seems like more work - what is the advantage?
  • What exactly are all the intermediate states?
  • Do they all work, and make complete sense as a working system? (Apparently not IMO.)
  • Is the transition from each one to the next fully BC? (Apparently not IMO.)
adamps’s picture

2. Whether we use the config or not, I don't see we have to wait on #3033301: Add formatters and other mechanisms as alternative to base fields directly in entity templates before we set isDispayConfigurable(TRUE).

Please see the end of the issue summary where I already presented a list of three possible ways to set isDispayConfigurable(TRUE) and their respective problems.

Many apologies Jonathan if I have caused offence. I'm really not wanting to shut down all debate, so I truly hope others will continue to contribute. I have found out the hard way that lots of ideas that seem promising turn out to be very difficult when you start to code them. If this issue becomes a dialogue of others saying "what about this or this or this" and I try to explain for each of them in turn where I think it will go wrong then it takes up more time that I currently have. Please do try to write some code and discover for yourself the answer to whether it works or not. Of course watch out for BC, especially if changing base field definitions or preprocessing. If anyone can produce a simpler solution that what I'm currently suggesting then I will be delighted.

adamps’s picture

Already in #27 and #29 I describe several problems that are apparently still present in the MR.

  1. It seems that anything deprecated in D9.4 would not get removed until D11.
  2. The title, UID and created fields are currently visible by default so I don't see how to write code for your concept "explicitly configured to be visible". As soon as someone saves their display settings, config will be saved for the newly visible base field. If the admin didn't explicitly change them, then the defaults will be saved. So I am speculating that the admin makes a minor adjustment to any field display and suddenly their title and submitted display switches to all the "disastrous" scenarios I described earlier.
  3. Suppose someone hides the title field because they don't want it displayed. This would apparently alter your algorithm and re-enable extra preprocessing meaning the title field actually is displayed based on node.html.twig.
jonathanshaw’s picture

No worries Adam. I'm going to focus anyway on #3270148: Provide a mechanism for deprecation of variables used in twig templates and more generic approaches to these deprecation challenges.

2. The title, UID and created fields are currently visible by default so I don't see how to write code for your concept "explicitly configured to be visible".

I thought we could get around that by setting the base field displayOption 'region' => 'hidden'. That's been what I've been trying to get across. But now I'm realising that's simply impossible, we depend on that to have the title at all!

It should have been obvious to me that my code:

  if (!$skip_custom_preprocessing && !isset($variables['elements']['title'] )) {
    $variables['label'] = $variables['elements']['title'];

is obviously nonsense. I'm check I use $variables['elements']['title'] after it fails an isset!

So we need your proposed configuration setting, sorry it took me a long time to get there.

However, I still don't see why this issue has to be postponed on #3033301: Add formatters and other mechanisms as alternative to base fields directly in entity templates. We can allow people to opt-in to configurable display long before we have developed a perfect replacement for the current non-configured approach. If they do opt-in, they might end up with odd feeble displays if they don't make use of custom or contrib formatters. But that's ok, it's just an option, we're not forcing anyone to use it, and surfacing it will probably help us get more contributors, make manual testing of new formatters easier, and lead to more contrib innovation around this.

adamps’s picture

However, I still don't see why this issue has to be postponed on #3033301

Please see end of issue summary. The text has been there for some while, and I've been trying to persuade you to read it😃.

The whole essence of the #2353867: [META] Expose Title and other base fields in Manage Display initiative is that Manage Display of base fields is broken. If we enable it without fixing the problem then we give everyone a broken UI. Any attempt to move the author field around in the display order has no effect. If you set a different formatter then it can cause invalid HTML inside a span tag.

jonathanshaw’s picture

I've read the IS. I'm saying exactly what @catch said to you in #19 above. It doesn't matter if enabling the opt-in makes stuff behave weirdly, it's simply an advanced option that it only makes sense to enable (at this point) if you have additional modules/themes that fix the problem.

adamps’s picture

It doesn't matter if enabling the opt-in makes stuff behave weirdly, it's simply an advanced option that it only makes sense to enable (at this point) if you have additional modules/themes that fix the problem.

Here is what @catch said

Right but there are lots of things you can do in manage display that don't actually look very good. It's not really different to adding a new field formatter that's incompatible with a custom or theme preprocess (which happened to me today).

In that case, the site owner would have to install a different theme, or if it's a custom theme, handle the fields differently in the template, and then update the configuration and theme at the same time.

Then in #23 I said this

As far as I can see it's unfortunately much more disruptive than that. I updated the IS with a list of options...

And in the IS is says this

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.

Only isDisplayConfigurable()

Here is my analysis on a possible patch that sets isDisplayConfigurable() but nothing else:

Sites that want the advanced behaviour can already have it right now, without any patch. They can enable Manage Display module, or some other custom module. It's simply a matter of calling isDisplayConfigurable() and $entity_type->->set('enable_base_field_custom_preprocess_skipping').

A patch that sets isDisplayConfigurable() leads to a broken user experience in Manage Display. How can you fix it? Well you can install Manage Display module. In which case the patch was unnecessary.

So I don't understand in what situation it is possible to benefit from this patch.

Changing base field definitions

In #27 item 1 I said this

The IS describes 'current' and 'new' base field definitions. How would you achieve the updating of the default type in Node::baseFieldDefinitions()? The current definitions seem highly unsuitable for use when base fields are present in Manage Display, so we need a strategy to change them. Arguably this is the key part of the whole BC debate, because there is no halfway option - somehow we need to make a change that's inherently not easily BC.

In my view, this is a strong argument for creating a setting. How else can we change the base field definitions? In the MR there is a commit that nonchalantly changes the formatter type of title, but as far as I can see that would be a significant BC break. If we have a setting, then it's very natural that it would also enable isDisplayConfigurable() etc. Hence the strategy proposed in the IS.

===

Anyway I'm exhausted from this debate. I have unsubscribed from this issue, and please feel free to create whatever patches you wish. I feel I have achieved something by completing stage A of the meta issue, and creating Manage Display module that works without patches to core. I'm quite ready for someone else to take over for the next stage.

Version: 10.0.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. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

ressa’s picture

Thanks for the herculean efforts here, getting "Title", "Authored on", and other relevant fields included in the Display manager, I very much appreciate it!

I'll just leave a comment here, that the overall task is not dead, even though the last comment here could give that impression, and dissuade interested developers ... because it looks like the idea reached a dead end.

But it is still being worked on, see the "META" issue #2353867: [META] Expose Title and other base fields in Manage Display :)

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.