如何告诉Drupal在模块目录中查找模板?
我想在我的模块中提供模板实现,并允许主题覆盖它。基本上,我通过以下简化代码添加建议: function attach_preprocess_node(&$vars) { $vars['theme_hook_suggestions'][] = 'node__test'; } (我不想使用hook_theme添加新主题,因为我想重用预处理节点功能。主题名称很尴尬,但我不想编写node_ attach _%以避免与节点类型混淆。) 然后,我使用hook_theme_registry_alter()添加模块路径: function attach_theme_registry_alter(&$theme_registry) { $path = drupal_get_path('module', 'attach') . '/themes'; $theme_registry_copy = $theme_registry; _theme_process_registry($theme_registry_copy, 'phptemplate', 'theme_engine', 'node', drupal_get_path('module', 'node')); $theme_registry += array_diff_key($theme_registry_copy, $theme_registry); if (!isset($theme_registry['node']['theme paths'])) { $theme_registry['node']['theme paths'] = array(); } if (!isset($theme_registry['node']['theme paths'])) { $first_element = array_shift($theme_registry['node']['theme …