Drupal在
theme registry
. 您可以创建一个自定义模块并实现
hook_theme_registry_alter()
检查主题注册表以查找主题正在使用的模板。从那里,您可以将主题文件夹与生成的列表进行比较。
实施示例:
function mymodule_theme_registry_alter(&$theme_registry) {
global $theme_path;
$templates_used = array();
foreach ($theme_registry as $theme) {
if (!empty($theme['template']) && $theme['path'] === $theme_path) {
$templates_used[] = $theme['template'] . '.tpl.php';
}
}
// Display the list (requires Devel module)
dsm($templates_used);
}
编辑
如果你不想实施
hook\u theme\u registry\u alter()
theme_get_registry()
获取主题注册表数组并使用上述技术检查模板文件。