Last active
December 15, 2015 20:59
-
-
Save rjpeter2/5322827 to your computer and use it in GitHub Desktop.
Have Drupal find your modules tpl overrides.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Create a variable to store the path to this module | |
define('MY_MODULE_PATH', drupal_get_path('module', 'pricing_calculator')); | |
/** | |
* Implements hook_theme_registry_alter(). | |
* | |
* Makes Drupal find our page template file. | |
* Found this at: http://drupal.org/node/715160 | |
*/ | |
function pricing_calculator_theme_registry_alter(&$theme_registry) { | |
$theme_registry_copy = $theme_registry; | |
_theme_process_registry($theme_registry_copy, 'phptemplate', 'theme_engine', 'hp_cloud_tile_site', MY_MODULE_PATH); | |
$theme_registry += array_diff_key($theme_registry_copy, $theme_registry); | |
// A list of templates the module will provide templates for | |
$hooks = array('page'); | |
foreach ($hooks as $h) { | |
// Add the key 'theme paths' if it doesn't exist in this theme's registry | |
if (!isset($theme_registry[$h]['theme paths'])) { | |
$theme_registry[$h]['theme paths'] = array(); | |
} | |
//Shift this module's directory to the top of the theme path list | |
if(is_array($theme_registry[$h]['theme paths'])) { | |
$first_element = array_shift($theme_registry[$h]['theme paths']); | |
if ($first_element) { | |
array_unshift($theme_registry[$h]['theme paths'], $first_element, MY_MODULE_PATH); | |
} else { | |
array_unshift($theme_registry[$h]['theme paths'], MY_MODULE_PATH); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment