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) {
if (($vars['view_mode'] === 'attach' || $vars['view_mode'] === 'attach_ajax')) {
$vars['theme_hook_suggestions'][] = 'attach__node__default';
$vars['theme_hook_suggestions'][] = 'attach__node__' . $vars['type'];
}'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($path);
}
However it does not work. I even tried a minimal example: use hook_theme_registry_alter() to add path to $theme_registry['node']['theme paths']
then place a node.tpl.php
in the module folder, but I failed to make it work.
Edit: in D6 the below code works
function attach_theme_registry_alter if (&$theme_registry!isset($theme_registry['node']['theme paths'])) {
// Put the$first_element themes= folderarray_shift($theme_registry['node']['theme atpaths']);
the lowest priority soif that($first_element) themes{
can override it.
// Attention:array_unshift($theme_registry['node']['theme itpaths'], seems$first_element, that$path);
advanced_forum removes the first}
path, so we'll beelse safe{
to be the 2nd.
array_splicearray_unshift($theme_registry['node']['theme paths'], 1,$path);
0, drupal_get_path('module', 'attach')); }
}
}
Edit 3/21: solution like http://drupal.org/node/715160However 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.