Themes cannot have a preprocess function without a corresponding .tpl.php file
| Project: | Drupal |
| Version: | 7.x-dev |
| Component: | theme system |
| Category: | bug report |
| Priority: | normal |
| Assigned: | JohnAlbin |
| Status: | patch (code needs work) |
Many times, sub-themes just need to tweak a variable in a tpl file and they don’t need to modify the tpl file's contents.
For example, if a sub-theme wants to modify the $submitted text, it doesn't need to modify the html/php in the base theme’s node.tpl.php.
Unfortunately, the auto-discovery phase of the theme registry building process first looks for tpl files in a theme and then for the corresponding preprocess functions. So if there isn't a tpl file, the theme registry building process won't look for a preprocess function.
No patch yet, but the way I envision this working is similar to the work-around that Zen 6.x-1.x has (#249532: Allow subthemes to have preprocess hooks without tpl files.). Grab the existing theme registry and loop through the known hooks (those that have tpl files), while looking for possible preprocess functions in the theme.

#1
Hm, this might qualify as a D6 bug indeed.
#2
This limitation is documented. A fix would be nice though.
Read the middle of this page in the list of notes:
http://drupal.org/node/223430
#3
Since the theme guide is amazingly accurate and based on the actual implementation (warts and all) and not based on the design, all the documented "limitations" fall into the "maybe this a bug" category. :-D
Let's see what the patch looks like and then decide whether this should be backported to D6.
#4
I am in favor of fixing this in D6 if the fix can be done without breaking the existing API, because it is a limitation that was not intended and causes quite a bit of acrobatics to get around.
#5
Please, please, please put this in. In D7 certainly, and it would be nice in D6 as well, so we don't need to wait a year for the awesomeness.
#277063: The next generation of DHTML Menu
#6
Here is a patch for D6.
I'd submit the D7 patch first, but I've tested this one.
#7
@Arancaytar: The patch is missing... ;)
#8
And in this case I can't even blame d.o. While rolling it, I got caught up in something and actually forgot. :P
#9
The patch is for Drupal 6, but succeeds on HEAD with offset. Still testing if it works too.
#10
I've ported my new DHTML menu module to D7 for testing purposes, and it works. Unfortunately my server is incapable of running simpletest reliably.
#11
I still don't know whether this patch will be allowed into Drupal 6 or will have to wait for Drupal 7...
#12
This is a documentation issue not a code one. Functions should have no preprocess for performance concerns. http://www.lullabot.com/articles/overriding-theme-functions-in-modules for a way .
#13
This has nothing to do with theme functions, it has to do with theme templates, chx.
#14
<?php@@ -596,7 +596,27 @@ function theme() {
}
if (isset($info['function'])) {
// The theme call is a function.
- $output = call_user_func_array($info['function'], $args);
?>
Huh what? This has nothing to with theme functions???? I am confused.
#15
chx: Arancaytar's patch is wrong, but that's no reason to bury the whole issue. The actual issue is about themes having preprocess functions but using an ancestor's template.
Arancaytar: Your patch is wrong. It shouldn't be intercepting theme functions. chx is right on that part; theme functions need to have the speediest route possible.