This is another way of making Drupal look for template overrides in your custom module. The question was asked by the Duke. How get a template in my module directory in to the theme registry?
I have a module which adds a new content type.
For this content type I want to supply a node_contenttype.tpl.php node type template, but Drupal will not recognize this template in the module directory, only in a theme.
How do I get Drupal (6) to use my template?
Laxman13 gives a great working solution which uses Drupal's directory template hints and search. If the content node type template is not found in the theme directory then this code makes Drupal look further into the modules path.
/** * Implementation of hook_theme_registry_alter() */ function mymodule_theme_registry_alter(&$theme_registry) { $template = 'node'; $originalpath = array_shift($theme_registry[$template]['theme paths']); $modulepath = drupal_get_path('module', 'mymodule'); // Stick the original path with the module path back on top array_unshift($theme_registry[$template]['theme paths'], $originalpath, $modulepath); }
Tags:
