I have a custom Drupal 6 module, with a custom theme function. I have implemented hook_theme in my mymodule.module (main module file) as follows:
function mymodule_theme() {
return array(
'mymodule_template_regions' => array(
'arguments' => array('template' => array()),
'file' => 'mymodule.theme.inc',
'path' => drupal_get_path('module', 'mymodule') . '/templates',
'template' => 'mymodule-template-regions',
),
);
}
I have implemented mymodule_preprocess_mymodule_template_regions() in a file called mymodule.theme.inc, in the main module folder.
I have placed mymodule-template-regions.tpl.php in the templates subfolder inside my main module folder.
This all works fine when the cache is cleared. As soon as the page is refreshed after the initial cache clear, it stops working.
The offending line is line 696 of theme.inc in Drupal Core version 6.19, which states:
if (function_exists($preprocess_function)) {
call_user_func_array($preprocess_function, $args);
}
When the cache is cleared, the mymodule_preprocess_mymodule_template_regions function exists, so it gets called because the 'if' statement yields TRUE. However, on each subsequent page request, the function does not exist. I presume this is because, for whatever reason, mymodule.theme.inc is not being included.
This is where my knowledge of Drupal breaks down, as I'm unaware of what else is going on here and how to track down why the function is not being included. It looks like the theme registry is still aware of mymodule_preprocess_mymodule_template_regions, but that it's simply not being called because it's not included.