Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drupal Features include Theme

Tags:

drupal

Is it possible to include a theme in a Drupal Feature? if so how?

like image 718
Linda Avatar asked Jun 11 '10 16:06

Linda


2 Answers

Not at the moment, unfortunately. Features basically consist of things that can be cleanly exported out of and imported into Drupal via various event hooks. Themes are an entirely different animal.

Theoretically, if you want to override some markup in your Feature (custom tpl.php files for your own content type for example), you could include the custom tpl.php file and use theme-related hooks in the Feature's module file to let Drupal know that the templates are in your module's directory.

like image 179
Eaton Avatar answered Sep 28 '22 09:09

Eaton


In addition to Eaton's answer. If you need to override an existing template (a .tpl.php file) provided by another module you can use hook_theme_registry_alter in YOUR_FEATURE.module:

function YOUR_FEATURE_registry_alter($theme_registry) {
  $originalpath = array_shift($theme_registry['TEMPLATE']['theme paths']);
  $featurepath = drupal_get_path('module', 'YOUR_FEATURE') .'/themes');
  array_unshift($theme_registry['TEMPLATE']['theme paths'], $originalpath, $featurepath);
}

In order for this to work, your feature should have a weight greater than the one of the module providing the overrided template. So in YOUR_FEATURE.install you will have something like

function YOUR_FEATURE_install() {
   db_query("UPDATE {system} SET weight = 10 WHERE name = 'YOUR_FEATURE'");
}
like image 27
Pierre Buyle Avatar answered Sep 28 '22 07:09

Pierre Buyle