Confusing API docs for hook functions

Created on 21 December 2016, over 7 years ago
Updated 11 July 2024, about 2 months ago

API page: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21...

IMHO the naming of hook functions in the API docs is confusing/misleading, e.g.

hook_theme_suggestions_HOOK_alter

Perhaps I'm being rather slow, but it took me some time before I realised the opening 'hook' was also a placeholder (for the theme name), not just the one in uppercase. I'd tried both of the following (for my 'test' theme) and XDebug (which not everyone will have setup) indicated they were not being matched:

hook_theme_suggestions_node_alter
test_hook_theme_suggestions_node_alter

when I actually needed:

test_theme_suggestions_node_alter

Could:
- the initial 'hook' also be in uppercase (in the explanatory text in the docs, I realise we can't change the code in core)
- OR it be named something else in uppercase, e.g. THEME/MODULE_theme_suggestions_HOOK_alter
- OR just provide example code with a named theme

Feature request
Status

Closed: outdated

Version

11.0 🔥

Component
Documentation 

Last updated 1 minute ago

No maintainer
Created by

🇬🇧United Kingdom wturrell

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.

Production build 0.71.5 2024