Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Problem/Motivation
The hook_theme_suggestions_HOOK() documentation states:
This hook allows the module implementing hook_theme() for a theme hook to provide alternative theme function or template name suggestions. This hook is only invoked for the first module implementing hook_theme() for a theme hook.
However this is the code:
// Invoke hook_theme_suggestions_HOOK().
$suggestions = $this->moduleHandler->invokeAll('theme_suggestions_' . $base_theme_hook, array($variables));
Proposed resolution
Update the documentation to indicate that this hook is invoked for all modules.
Remaining tasks
- Patch
- Review
User interface changes
n/a
API changes
n/a
Comment | File | Size | Author |
---|---|---|---|
#18 | interdiff.txt | 996 bytes | wadmiraal |
#18 | drupal_hook_theme_suggestions_HOOK-documentation_2430909_18.patch | 1.16 KB | wadmiraal |
#11 | 2430909_hook_theme_suggestions_10.patch | 1.54 KB | harshil.maradiya |
#9 | hook_theme_suggestion_correction-2430909-9.patch | 879 bytes | joshi.rohit100 |
#7 | hook_theme_suggestion_correction-2430909-7.patch | 739 bytes | anwar_max |
Comments
Comment #1
BerdirNote: We noticed this because of http://drupal.stackexchange.com/questions/141373/drupal-8-custom-page-te...
Comment #2
jrhodes07 CreditAttribution: jrhodes07 commentedHere's a patch that updates the documentation:
Comment #3
star-szrThanks @ClientGuy :)
The hook is invoked for all modules, period. So this whole paragraph should be updated, something like this might do it:
"This hook allows modules to provide alternative theme function or template name suggestions."
Comment #4
anwar_maxComment #5
anwar_maxAs per #3 changes have been made to the patch.
Comment #6
anwar_maxComment #7
anwar_maxUploaded empty patch. Re-uploading the patch.
Comment #8
BerdirThat still doesn't make sense, the part hook_theme() needs to go. As @Cottser said, it is called for all modules. full stop.
Comment #9
joshi.rohit100updated patch.
Comment #10
star-szrMuch closer, thanks!
Arguably "This hook is invoked for all modules" is the default and therefore redundant, but I'm fine either way on that. Might be worth looking around at other *.api.php's as an example.
This part actually should be updated too I think, because it seems to reflect the previous paragraph where only the module implementing hook_theme() would get the hook invocation.
Here's the full couple sentences:
Comment #11
harshil.maradiya CreditAttribution: harshil.maradiya commentedUpdated
Comment #12
harshil.maradiya CreditAttribution: harshil.maradiya commentedComment #16
star-szr@harshil.maradiya - Patch is corrupt according to git, missing newline at EOF I think.
All my comments from #10 still apply. I don't think we should change the docs for hook_theme_suggestions_HOOK_alter() in this issue. Can we go back to the patch from #9 please and provide interdiffs when making changes to patches? Thanks all! :)
Comment #17
wadmiraal CreditAttribution: wadmiraal commentedI'll get it.
Comment #18
wadmiraal CreditAttribution: wadmiraal commentedUpdated documentation. I checked other *.api.php files: they don't mention "this is invoked for all modules" (it is kind of implicit).
Comment #19
wadmiraal CreditAttribution: wadmiraal commentedComment #20
jhodgdonLooks great to me, thanks!
Comment #21
alexpottCommitted c9a38f1 and pushed to 8.0.x. Thanks!