The Omega 4.2 includes a default omega/theme/field.theme.inc file that contains omega_field(). We can override this in our own THEMENAME/theme/field.theme.inc as THEMENAME_field().

theme_field() lets you have varying levels of specificity based on field name and where the field is used, eg

  • THEMENAME_field__body__article()
  • THEMENAME_field__article()
  • THEMENAME_field__body()
  • THEMENAME_field()

How do we name the include files for these varying levels of specificity? I have tried several combinations of dashes and underscores without luck.

The also comes up with some other theme functions (eg, theme_menu_links()), but I have not explicitly tested those.

Sorry if this is a duplicate or in the handbook. I searched for a while w/o luck.

Comments

fubhy’s picture

Status: Active » Fixed

Simple!

field--body--article.theme.inc with THEMENAME_field__body__article() as function in it.

:)

mpdonadio’s picture

Category: Support request » Bug report
Status: Fixed » Active

I think I may have discovered a bug with this feature (or possibly a bug in core).

I cannot get the specific versions of the theme_field() functions to work if they are in include files. I can examine the registry, and verify that the function name and include file names are correct.

I think the problem has to do with the ordering of things in theme().

Around lines 1062--1066, theme() will include_once the files for the element.

Then, around 1120 (line numbers may be off b/c debug info I have), it executes the preprocess and process functions.

The default template_preprocess_field() sets up the theme_hook_suggestions to specify the more specific versions.

Then, around lines 1133--1157, theme() will check the registry for the suggestions, and reset which entry it is using. At no point onward will it include_once the files for this element.

If I patch theme() to include files after the reassignment, all is well.

mpdonadio’s picture

Status: Active » Closed (duplicate)

I opened this as a core bug at https://drupal.org/node/2244579 with a patch, as I don't see why this should be the theme's responsibility. In hindsight, I should have reassigned this issue...