Skip to content

Instantly share code, notes, and snippets.

@fede-green
Last active October 9, 2017 11:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fede-green/64236f050752bc5913199630f2b92cc4 to your computer and use it in GitHub Desktop.
Save fede-green/64236f050752bc5913199630f2b92cc4 to your computer and use it in GitHub Desktop.
Module implementing custom template suggestions altering an already existing hook.
/**
* Implements hook_theme_suggestions_HOOK_alter().
*/
function MYMODULE_theme_suggestions_HOOK_alter(array &$suggestions, array $variables) {
array_unshift($suggestions, 'ADD_MY_MODULE_SUGGESTION');
}
/**
* Implements hook_theme_registry_alter().
*/
function MYMODULE_theme_registry_alter(&$theme_registry) {
// Adding this modules's templates to the bunch.
// Html.html.twig
$theme_registry['ADD_MY_MODULE_SUGGESTION'] = $theme_registry['html'];
$theme_registry['ADD_MY_MODULE_SUGGESTION']['path'] = drupal_get_path('module', 'MYMODULE') . '/templates';
$theme_registry['ADD_MY_MODULE_SUGGESTION']['template'] = 'MY--TEMPLATE';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment