Remove the ability to provide a 'pattern' in hook_theme()

Created on 13 August 2013, about 12 years ago
Updated 19 August 2025, 2 months ago

Problem/Motivation

There are far, far too many ways to do exactly the same thing in Drupal. In particular, there are 4 ways to provide theme_hook_suggestions for Drupal 8:

  1. provide a pattern in hook_theme
  2. implement hook_template_suggestions()
  3. implement hook_template_suggestions_alter()
  4. pass an array to theme()

Proposed resolution

If we were to remove pattern from hook_theme, there would only be three ways to do the same thing.

From the API:

pattern: A regular expression pattern to be used to allow this theme implementation to have a dynamic name. The convention is to use __ to differentiate the dynamic portion of the theme.

For all current uses of 'pattern' in core we should use hook_template_suggestions() instead.

Remaining tasks

Remove pattern from hook_theme().

User interface changes

None.

API changes

Remove pattern from hook_theme().

Related Issues

#1751194: Introduce hook_theme_suggestions[_HOOK]() and hook_theme_suggestions[_HOOK]_alter() β†’

πŸ“Œ Task
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

theme system

Created by

πŸ‡ΊπŸ‡ΈUnited States jenlampton

Live updates comments and jobs are added and updated live.
  • API change

    Changes an existing API or subsystem. Not backportable to earlier major versions, unless absolutely required to fix a critical bug.

  • stale-issue-cleanup

    To track issues in the developing policy for closing stale issues, [Policy, no patch] closing older issues

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 smustgrave

    Thank you for creating this issue to improve Drupal.

    We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.

    Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

Production build 0.71.5 2024