Drupal 6 - Custom Node Typical Template in a Module

I have a module that adds a new content type.

For this content type, I want to specify a template of type node_contenttype.tpl.php node but Drupal does not recognize this template in the module directory, only in the subject.

How do I get Drupal (6) to use my template?

+8
drupal drupal-6 drupal-theming drupal-modules
source share
1 answer

You can use hook_theme_registry_alter ()

Here is an example of its use in a custom module that works for me (just replace "mymodule" with your module name):

/** * 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); } 

Now Drupal will check your module folder to override the node template.

+10
source share

All Articles