Buried in the D6 theme guide is this note:
In order for your theme to have its preprocessors recognized, the template associated with the hook must exist inside the theme. When a default template exists, copy it to your theme and clear the registry.
This would mean that a sub-theme would have to have copy of all of Zen core’s .tpl.php files. Unless we can figure out a better way to handle it.
When I talked to Earl about this, he said…
Hmm, in D6 you'd implement hook_theme, run the auto discovery function and get its results; then do your own check for theme_* functions. If the hook was already discovered, ignore it; if it wasn't, add it to your list and make sure you keep path information
…which I will have to translate into actual code and play around with.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | hook-theme.patch | 8.08 KB | johnalbin |
Comments
Comment #1
johnalbinInitial notes:
Comment #2
Steven_NC commentedI am going to show my ignorance here. What would happen if Zen always had a sub-theme and was factored for that?
Comment #3
johnalbinOk. I tried to return the preprocess functions from a HOOK_theme() call, but _theme_process_registry() sees the new SUBTHEME_preprocess_HOOK function, looks for a HOOK.tpl.php in the subtheme and, when it doesn't find it, assumes you must want to use a SUBTHEME_HOOK() function to build the template. And, thus, it all falls apart.
The documention for HOOK_theme shows this:
Fortunately, I discovered that if I implement it like so:
I can manipulate the registry cache ($existing) directly. Sweet. Not sure if I'm abusing the HOOK_theme() call, but its the only way to fix this issue.
I'm attaching the patch for reference.
Comment #4
johnalbinCommitted.
Comment #5
johnalbinRight now, the patch allows sub-themes to have preprocess functions for any of the preprocess functions used in the base Zen theme (page, node, block, comment). But I think it would be good to expand this to allow preprocess functions for any HOOK that has a tpl file (regardless if the tpl is in the Zen theme or not.)
Comment #6
johnalbinOk. I've optimized the code and expanded it to apply preprocess functions to ALL hooks, not just the four used in zen's template.php page.
Comment #7
andershal commentedHey JohnAlbin, could you attach your updated patch?
Comment #8
johnalbinThe patch in #6 is available here: http://cvs.drupal.org/viewvc.py/drupal/contributions/themes/zen/zen/temp...
Of course, it patches the code that was patched in #4. If you want the entire code, the heart of the patch is the HOOK_theme() hook function; you can find the entire hook (called zen_theme, of course) in zen/template.php in the 6.x-1.0-beta1 release.
Comment #9
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.