Make field template suggestions and preprocess work

Created on 29 March 2017, over 7 years ago
Updated 29 December 2023, 12 months ago

Follow up from #2856283: Overridden twig field templates have empty content .

Quoted from a comment there:

Ok, we have the same problem as in #2860490: Invalid argument supplied for foreach() in ds_preprocess_ds_layout() line 366 of ds.module . We committed a fix there which we can remove if when #2861840: Preprocess functions are not merged when a module registers a theme hook for a theme-provided template is committed to core. We'll probably need a similar workaround for the field templates too.

Further more, since we're also using a 'base hook' for the DS field templates, this means suggestions won't work, just like in #2802429: Display layout twig not overridable. . That added an insane workaround which we hopefully can remove if we have a solution in #2862683: 'base hook' key prevents template suggestions from working . Will look if I can come up with the same crazy workaround for field templates.

Part one is done. Now part two: make sure all suggestions work and add some more tests. Suggestions for field templates are a bit different than we do for layouts, so the insane workaround which exists didn't work out of the box. So either

  • we need to alter that work around a bit more to discover the right theme hooks
  • change the suggestions, but that's maybe BC break ?

See also 🐛 Field template suggestion is wrong when global default is overridden Active , 🐛 Field Template Suggestions Not Getting $variables['settings'] Closed: duplicate and 🐛 template_preprocess_field breaks DS field layout Closed: duplicate

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇧🇪Belgium swentel

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