function show_title_theme_registry_alter in Show title 8
Same name and namespace in other branches
- 2.0.x show_title.module \show_title_theme_registry_alter()
Implements hook_theme_registry_alter().
File
- ./
show_title.module, line 193 - Module Show Title.
Code
function show_title_theme_registry_alter(&$theme_registry) {
$active_theme = \Drupal::theme()
->getActiveTheme();
// Check if file not exist in active theme.
if (!file_exists($active_theme
->getPath() . '/templates/node.html.twig')) {
// Check if theme has base theme to select the right overrided template.
// Base theme stable is default core template.
$base_theme = 'stable';
if (!empty($active_theme
->getExtension()->base_theme)) {
$base_theme = $active_theme
->getExtension()->base_theme;
}
// Set the branding block template.
$module_path = drupal_get_path('module', 'show_title');
$theme_registry['node']['path'] = implode('/', [
$module_path,
'templates',
$base_theme,
]);
}
}