hook_theme_suggestions_page_alter does not permanently remember it's template suggestions

Created on 31 July 2018, about 6 years ago
Updated 2 May 2024, 4 months ago

I have the following issue when trying to use a custom page template for a specific route. My custom template is only used for a limited time (after cache clear). This time varies from 5 minutes to half an hour. After that, the regular page template is used.

Test code:

/**
 * Implements hook_theme_suggestions_hook_alter().
 */
function THEMENAME_suggestions_page_alter(&$suggestions, $variables) {
  $route_name = \Drupal::routeMatch()->getRouteName();
  if ($route_name == 'my.route.name') {
    $suggestions[] = 'page__customtemplate';
  }
}

My template name:

page--customtemplate.html.twig

Any ideas on why Drupal handles this only for a short period of time?

🐛 Bug report
Status

Closed: cannot reproduce

Version

11.0 🔥

Component
Theme 

Last updated 1 day ago

Created by

🇧🇪Belgium wouter.dierick

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States bnjmnm Ann Arbor, MI

    Unable to reproduce.

    If the person reporting this is still experiencing the issue 6 years later by all means reopen with additional information about the environment this issue is happening in.

Production build 0.71.5 2024