Drupal features include a theme

Can I include a theme in a Drupal function? if so, how?

+7
drupal
source share
2 answers

At the moment, unfortunately. Features mainly consist of things that can be easily exported and imported into Drupal using various event hooks. Themes are a completely different animal.

Theoretically, if you want to override some markup in your function (for example, custom tpl.php files for your own content type), you can include a custom tpl.php file and use theme-related bindings in the Feature module file so that Drupal knows that the templates are in your modules directory.

+5
source share

In addition to Eaton's answer. If you need to override an existing template (.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 function must have a weight greater than the weight of the module providing the overridden 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'"); } 
+1
source share

All Articles