As of now, we can do the following overrides for field templates:

  • content-field-<FIELD_NAME>-<CONTENT_TYPE_NAME>.tpl.php
  • content-field-<CONTENT_TYPE_NAME>.tpl.php
  • content-field-<FIELD_NAME>.tpl.php

What I would really like to see is the ability to do the same kind of overrides by field type. For example, if you want to create a default for all imagefields, or all text fields, etc. We often override by field, but it would be nice to override all fields of a certain type (regardless of the content type), with a pattern like this:

  • content-field-<FIELD_TYPE_NAME>.tpl.php

I'm not sure if this is easy or asking for the moon, but being a very heavy user for field overrides this would be incredibly useful for me. Not sure if it would be for anybody else.

One benefit that I see is for theme developers. You could include field templates in your theme and be insured that particular fields would be outputted a certain way, regardless of what they are called. It's not possible to do the other patterns ahead of time in a theme, since you never really know what people will call their fields or content types.

Sincerely,
Rene

Comments

yched’s picture

I can understand the use case. Main problem with adding yet another 'dimension' for template names is managing all the combinations and precedencies.
Other that that, this is technically really easy - just requires changing $additions['template_files'] at the end of content_preprocess_content_field(), so if anyone wants to tackle a consistent implementation update the advanced_help page(theme-field-template.html), be my guest :-)

Meanwhile, you can do that yourself in your theme, actually :

function phptemplate_preprocess_content_field(&$vars) {
  // Do what you want with $vars['template_files']
}

See http://drupal.org/node/223430 for more information.