Problem/Motivation

It is currently possible to create a page template specific to a node, but not specific to a content type shared by multiple nodes. The latter would be far useful.

Proposed resolution

Incorporate the actions of the following hook into core.

function HOOK_theme_suggestions_page_alter(array &$suggestions, array $variables) {
  if (array_search('page__front', $suggestions) === FALSE ) {
    if ($node = \Drupal::routeMatch()->getParameter('node')) {
      $content_type = $node->bundle();
      if ($content_type) {
        $suggestions[] = 'page__bundle_' . $content_type;
      }
    }
  }
}

Remaining tasks

User interface changes

API changes

Twig templates with page__bundle_[some content type].html.twig will be automatically picked up without the need for additional hooks. This could conflict with any implementations of the above hook.

Data model changes

Comments

Aki Tendo created an issue. See original summary.

Aki Tendo’s picture

Issue summary: View changes

Updating code snippet above to not provide the bundle on the front page, which confuses twig into loading the bundle template instead of the front_page template.

dawehner’s picture

Note: The snipped would ideally take into account the entity type as well.

joelpittet’s picture

Issue tags: -theme

I wonder how this plays into layouts initiative?