I'd like to provide template implementation in my module and allow themes to override it. Basically, I add a suggestion by this simplified code:
function attach_preprocess_node(&$vars) {
$vars['theme_hook_suggestions'][] = 'node__test';
}
(I don't want to use hook_theme to add a new theme because I want to reuse preprocess node functions. The theme name are awkward but I don't want to write node_attach_% to avoid confusion with node type.)
Then I use hook_theme_registry_alter() to add module path:
function attach_theme_registry_alter(&$theme_registry) {
$path = drupal_get_path('module', 'attach') . '/themes';
$theme_registry_copy = $theme_registry;
_theme_process_registry($theme_registry_copy, 'phptemplate', 'theme_engine', 'node', drupal_get_path('module', 'node'));
$theme_registry += array_diff_key($theme_registry_copy, $theme_registry);
if (!isset($theme_registry['node']['theme paths'])) {
$theme_registry['node']['theme paths'] = array();
}
if (!isset($theme_registry['node']['theme paths'])) {
$first_element = array_shift($theme_registry['node']['theme paths']);
if ($first_element) {
array_unshift($theme_registry['node']['theme paths'], $first_element, $path);
}
else {
array_unshift($theme_registry['node']['theme paths'], $path);
}
}
}
However it does not work. That means: the file themes/node--super.tpl.php is not used. It is used only if I copied it to the theme folder.