Skip to content

Instantly share code, notes, and snippets.

@jfitzsimmons2
Created May 10, 2017 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfitzsimmons2/ca3f0026650d597f06aabc33a8965435 to your computer and use it in GitHub Desktop.
Save jfitzsimmons2/ca3f0026650d597f06aabc33a8965435 to your computer and use it in GitHub Desktop.
<?php
/**
* Implements hook_theme_registry_alter().
*/
function MODULENAME_theme_registry_alter(&$theme_registry) {
// Defined path to the current module.
$module_path = drupal_get_path('module', 'MODULENAME');
$module_path .= '/templates';
// Find all .tpl.php files in this module's folder recursively.
$template_file_objects = drupal_find_theme_templates($theme_registry, '.tpl.php', $module_path);
// Iterate through all found template file objects.
foreach ($template_file_objects as $key => $template_file_object) {
// If the template has not already been overridden by a theme.
$theme_registry[$key]['theme path'] = $module_path;
$theme_registry[$key] = array_merge($theme_registry[$key], $template_file_object);
$theme_registry[$key]['type'] = 'module';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment