I've used the Features module to create a feature and I'm trying to add a tpl file to that feature but I can't get Drupal to recognize it. The feature is basically a cck content type and some imagecache settings. Normally I could add a tpl to the the site 's enabled theme folder and it would work fine, but I'm trying to create a bunch of features that can easily be used on any site with any theme. Anyone have any ideas?

Thanks!

Comments

John Carbone’s picture

Figures. After searching for hours, reading articles and general head scratching, I finally came across this http://hddigitalworks.com/theming-cck-content-type which includes a section called "theming from a module" about 10 minutes after posting this topic. In case anyone else ends up wondering the same thing, here's how I did it.

After creating my tpl and adding it to my module's folder, I opened my MYMODULE.module file and added the following:

function MYMODULE_theme_registry_alter(&$theme_registry) {
  $my_path = drupal_get_path('module', 'MYMODULE');
  $hooks = array('node');  // you can do this to any number of template theme hooks
  // insert our module
  foreach ($hooks as $h) {
    _MYMODULE_insert_after_first_element($theme_registry[$h]['theme paths'], $my_path);
  }
}
 
function _MYMODULE_insert_after_first_element(&$a, $element) {
  $first_element = array_shift($a);
  array_unshift($a, $first_element, $element);
}
 

After flushing the site's caches to rebuild the theme registry, my tpl.php was finally being called by the Feature. Sweet!