Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
oembedfield-formatter-theme.patch | 1.19 KB | Anonymous (not verified) |
Comments
Comment #1
voxpelli CreditAttribution: voxpelli commentedDon'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.
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedFor 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.
Comment #3
Anonymous (not verified) CreditAttribution: Anonymous commentedI've added an issue for this part of Drupal's theme system to be documented. #909954: Document 'base hook' in hook_theme()
Comment #4
voxpelli CreditAttribution: voxpelli commentedAfter 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.