file include fails when a template is overridden
fago - September 29, 2008 - 13:41
| Project: | Drupal |
| Version: | 6.x-dev |
| Component: | theme system |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
I noticed the bug in content profile: http://drupal.org/node/302873
As long as the template provided by the module is used, the file stated in the 'file' property is included and the preprocess function is called. Once the theme overrides the template, the file isn't included any more and so the preprocess function lieing in the file isn't invoked. I noticed that in the theme registry the 'file' property isn't set any more in this case.

#1
I too have just noticed this issue. I however do not think this is a bug, but more by design.
I originally had my template preprocess functions in a separate file, which I had included by setting the 'file' and 'path' properties in my modules hook_theme. I got the idea to do this from the hook_theme documentation of the file property here.
The current implementation would allow the theme to set the 'file' and 'path' properties which allow's the theme to break all its stuff out into separate files. This of course, then breaks the module includes, which might be needed to ensure template preprocess functions are run.
There are several solutions and workarounds, and I'm not sure which one would be best, but at the very least, the documentation for hook_theme should be updated to indicate that if a module puts its template_preprocess_HOOK functions in a separate file, that the file will not be included if a theme overrides the template, and that the module will need to load the file itself.
Solutions could include:
None of those options seem ideal. At the very least, this needs to be documented somewhere.
This is only a problem when include files contain the preprocess functions, normal theme function overrides will not cause this problem.