Drupal Features include Theme

2019-06-18 04:37发布

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

标签: drupal
2条回答
ら.Afraid
2楼-- · 2019-06-18 04:49

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.

查看更多
Evening l夕情丶
3楼-- · 2019-06-18 04:55

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'");
}
查看更多
登录 后发表回答