I am trying to have one tpl file per view mode inside a module folder. But I can't get drupal to pick up the right tpl file.
I have been trying solutions on these pages:
http://www.metachunk.com/blog/adding-module-path-drupal-7-theme-registry
/**
* Implements hook_theme_registry_alter()
**/
function nwd_press_room_theme_registry_alter(&$theme_registry) {
global $theme_key;
$mod_path = drupal_get_path('module', 'nwd_press_room');
$theme_registry_copy = $theme_registry; // munge on a copy
_theme_process_registry($theme_registry_copy, 'phptemplate', 'theme_engine', $theme_key, $mod_path);
$theme_registry += array_diff_key($theme_registry_copy, $theme_registry);
$hooks = array('node');
foreach ($hooks as $h) {
if (!isset($theme_registry[$h]['theme paths'])) {
$theme_registry[$h]['theme paths'] = array();
}
nwd_press_room_insert_after_first_element($theme_registry[$h]['theme paths'], $mod_path);
}
dpm($theme_registry);
}
/**
* Helper function for re-ordering arrays (needed by theme_registry_alter)
*/
function nwd_press_room_insert_after_first_element(&$a, $element) {
if(is_array($a)) {
$first_element = array_shift($a);
if ($first_element) {
array_unshift($a, $first_element, $element);
} else {
array_unshift($a, $element);
}
}
}
Since I still want the tpl file to be overridable in the theme. Does anyone have an example that works?