Skip to content

Instantly share code, notes, and snippets.

@rpayanm
Last active June 30, 2020 16:59
Show Gist options
  • Save rpayanm/1188b06880b5e6346b182fe666ca28f7 to your computer and use it in GitHub Desktop.
Save rpayanm/1188b06880b5e6346b182fe666ca28f7 to your computer and use it in GitHub Desktop.
// Para que busque el template en el módulo.
/**
* Implements hook_theme().
*/
function modulename_theme($existing, $type, $theme, $path) {
$templates_path = $path . '/templates/';
return [
'node__content_type' => [
// El base_hook en este caso es node.
'base hook' => 'node',
// Si queremos que tenga otro nombre el template.
'template' => 'my-custom-name',
// Si queremos que busque en otra carpeta.
'path' => $templates_path . 'content',
],
];
}
// Si se quiere sobrescribir el template de la página `node__content_type`, pues el template ya está en el theme.
/**
* Implements hook_theme_registry_alter().
*/
function my_module_theme_registry_alter(&$theme_registry) {
$theme_registry['node__content_type']['path'] = drupal_get_path('module', 'my_module') . '/templates';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment