- 🇬🇧United Kingdom catch
Unpostponed finally.
📌 Investigate preprocess_field in the comment module Active was dealing with this problem, and we can tidy up that preprocess implementation here probably.
Postponed on #3159050: Allow deprecating theme suggestions →
Currently, core has 4 theme hook suggestions for the "field" theme hook:
field--[field-type].tpl.php
field--[field-name].tpl.php
field--[bundle].tpl.php
field--[field-name]--[bundle].tpl.php
Note: that the field name is prefixed with the name of the module providing the field, which usally means “field-” is prefixed to the field name. Also, note that the "bundle" is a sub-type of an entity, e.g. “content types” are bundles since an "article" is a bundle of the node entity.
The theme hook suggestions are supposed to be in order of specificity. With least specific suggestions appearing first in the list. Suggestions at the end of the list override suggestions earlier in the list.
Unfortunately, the field--[field-name].tpl.php
and field--[bundle].tpl.php
suggestions are in the wrong order. A specific field should take precedence over "any field attached to this bundle". A fix for this should be backported to D7.
We also have a namespacing issue. If the same name is used for the bundle name or the field name or the field type, it can cause unintended issues. For example, if a user creates an "image" content type there will be a namespace collision with any fields that are the "image" field type; field--[field-type]
and field--[bundle]
would both be field--image
. If a themer wanted to use a theme hook suggestion for all image-type fields (perfectly reasonable!), they would also accidentally trigger the bundle-based suggestion on all fields attached to the image content type (perfectly horrible!)
Fix the order of specificity for theme hook suggestions, namely:
field--[field-type].tpl.php
field--[bundle].tpl.php
field--[field-name].tpl.php
field--[field-name]--[bundle].tpl.php
Come up with a way to properly namespace theme hook suggestions so that bundle-based suggestions don't conflict with type-based suggestions. Note that field names are currently prefixed with the name of the module implementing the field, which almost universally means a field name is prefixed with "field-".
See here for a workaround that provides a solution for adding theme suggestions for fields based on display mode: https://drupal.stackexchange.com/questions/201210/field-template-for-dis...
Needs work
11.0 🔥
theme system
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Unpostponed finally.
📌 Investigate preprocess_field in the comment module Active was dealing with this problem, and we can tidy up that preprocess implementation here probably.