The bug appears to be that oembedfield_theme() sets the preprocessor functions array, which means Drupal's theme registry builder doesn't look for preprocessor functions itself. And I can't use preprocessor hooks for specific formatters either.

The fix is to use the 'original hook' attribute of the theme info.

CommentFileSizeAuthor
oembedfield-formatter-theme.patch1.19 KBAnonymous (not verified)
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

voxpelli’s picture

Status: Needs review » Needs work

Don't you think we should use the 'pattern' attribute instead? Like eg. Views does. It's a documented property while 'original hook' seems like an undocumented internal property of the theming system: http://api.drupal.org/api/function/hook_theme/6

With 'pattern' we would just define one theme like 'oembedfield_formatter_oembed' and set its property 'pattern' to 'oembedfield_formatter_oembed__' and it would work for all presets like 'oembedfield_formatter_oembed__mysupercoolpresetname'.

The downside of that though is that it's a breaking theme change so I would like to wait with that for at least a few weeks.

Setting as "needs work" for now.

Anonymous’s picture

Status: Needs work » Needs review

For a theme pattern to use the original preprocess functions, the original hook needs to be declared in hook_theme. This was added to Drupal 6 to support Views. You can see the thread #241570: Theme preprocess functions do not get retained when using patterns.

Currently, the explicit declaration of preprocessor functions is a bug. It means I cannot specify a preprocessor function in my own modules without also adding them to the theme in a hook_theme_registry_alter() because the theme rebuilder won't bother to look for preprocessor functions because it already knows what they are.

This patch has no effect for the module as is, but it allows me to add more preprocessor functions and add preprocessor functions that match the actual theme being called by the formatter.

Anonymous’s picture

I've added an issue for this part of Drupal's theme system to be documented. #909954: Document 'base hook' in hook_theme()

voxpelli’s picture

Status: Needs review » Fixed

After some testing and some talking to bangpound on IRC I've come to the conclusion that this is patch is a better solution than the previous theme-solution. Committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.