1

I want to override the page.html.twig template from a custom module. I know how to create a suggestion, but I would like it to find the template file in my custom module.

function promo_accc_theme_suggestions_page_alter(array &$suggestions, array $variables) {
    $suggestions[] = 'page__promo__accc';
}

I'm not sure what I would need to do from here to get Drupal to look in /custom/modules/promo_accc/templates.

-1

drupal_get_path('module',$module_name) function will return the path to your custom module so:

function promo_accc_theme_suggestions_page_alter(array &$suggestions, array $variables) {
    $suggestions[] = drupal_get_path('module','promo_accc').'/templates/page__promo__accc';
}

for more info about the drupal_get_path() function: https://api.drupal.org/api/drupal/core%21includes%21bootstrap.inc/function/drupal_get_path/8.7.x

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.