API page: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21...
The docs for this say:
path: Override the path of the file to be used. Ordinarily the module or theme path will be used, but if the file will not be in the default path, include it here. This path should be relative to the Drupal root directory.
But this is not quite true. As seen in Drupal\Core\Theme\Registry:
* In case of a theme template file:
* - path: The path to the template file to use. Defaults to the
* subdirectory 'templates' of the path of the extension implementing
* hook_theme(); e.g., 'core/modules/node/templates' for Node module.
It's a 'templates' subfolder in the module.
| Comment | File | Size | Author |
|---|---|---|---|
| #45 | 2867796-45.patch | 1.24 KB | kunalgautam |
| #34 | after-patch-2867796-33.png | 309.34 KB | vinmayiswamy |
| #33 | interdiff_30_33.txt | 1.22 KB | ameymudras |
| #33 | 2867796-33.patch | 1.24 KB | ameymudras |
| #30 | interdiff_23-30.txt | 1.19 KB | Ratan Priya |
Comments
Comment #11
jeroentComment #12
jeroentComment #13
anagomes commentedComment #14
anagomes commentedThis is my understanding from the issue summary, but I'm not sure if that's what it is really about. Any opinions/suggestions are welcome.
Comment #16
elberHi I reviewed the patch and for me the new description managed to describe it correctly
Comment #17
murilohp commentedI think #14 needs a reroll to 9.5.x, I've made this one, moving back to NR.
Comment #18
murilohp commentedOooops, my bad, here's a new one.
Comment #19
andregp commentedThe new text sounds reasonable for me.
Comment #20
alexpottThis change is not correct. If you don't supply the path in your hook_theme (this is the norm) it will default to the extension's templates directory. If you do supply a path then in needs to be relative to the root directory.
I think the wrong bit of the documentation has been changed. I think we could change the
Ordinarily the module or theme path will be usedas ordinarily the path will be set to the template directory in the module or theme's directory ifSee...
in \Drupal\Core\Theme\Registry::processExtension
FWIW the
isset($result[$hook]['template'])check is superfluous - it is guaranteed to be set because of prior code in the method.Comment #21
sophiavs commentedHi, i'll try to work on those changes specified in #20.
Comment #22
sophiavs commentedI tried to analyze better the theme api, but couldn't think in others change to the doc, so i only inset the text suggested in #20
Comment #23
sophiavs commentedComment #24
vinmayiswamy commentedI applied #23 patch against Drupal 9.5.x-dev and I can see that the text updated as suggested in #20.
Thanks @sophiavs
Comment #25
gquisini commentedI'll be reviewing
Comment #26
gquisini commentedThe same as #24.
I applied the #23 patch and the hook_theme() docblock has the changes suggested in #20.
Comment #28
ameymudras commentedPatch failed because of unrelated issue, marking this issue as RTBC again
Comment #29
alexpottIt's the
templatesdirectory.The original text of the last sentence is correct and should not be changed - it should be
This path should be relative to the Drupal root directory.Comment #30
Ratan Priya commented@alexpott,
Made changes as per comment #29.
Needs review.
Comment #31
alexpottHere's what I think the text should be:
I think this format is better because it begins with
If specified,so you immediately know it does not have to be. And then it tells you want you should do if you do want to specify it. And finally it tells you the default behaviour if you don't specify it.Comment #32
alexpottComment #33
ameymudras commentedChanged the text as per your suggestion
Comment #34
vinmayiswamy commentedI applied #33 patch against Drupal 9.5.x-dev and the hook_theme() docblock has the changes suggested in #31.
Thanks @ameymudras
Comment #36
smustgrave commented#33 made the change per @alexpott recommendation in #31
Comment #37
larowlanAdding credits
Comment #38
larowlanThis no longer applies to 10.1.x, can we get a re-roll.
We will likely need two patches, as it still applies to 9.5.x
Comment #39
kunalgautam commentedPatch for Drupal version 10.1.x
Comment #40
elberHi I rewiewed the last patch.
I was able to apply in drupal 10.1 version.
Issues changes keep there.
Core keep working as expected.
Moving to RTBC
Comment #41
alexpottThe patch #39 contains lots of changes that are not supposed to be there. For example, it changes the root composer.json to install drush :)
Comment #42
elberok sorry I will work on it
Comment #43
elberComment #44
elberHi I couldn't work on that
Comment #45
kunalgautam commentedThanks @alaxpott. It's my bad.
I have uploaded the updated patch.
Comment #46
kunalgautam commentedComment #47
elberok now it's good.
I was able to apply in drupal 10.1 version.
Issues changes keep there. (no unrelated changes)
Core keep working as expected.
Moving to RTBC.
Comment #48
alexpottCommitted f570135 and pushed to 10.1.x. Thanks!
Committed 85b728e and pushed to 10.0.x. Thanks!
Didn't apply to 9.5.x so I didn't backport there and I'm not sure it's worth it.
Comment #51
alexpottFound a 9.5.x version in #33 and committed that.
Committed 543019b and pushed to 9.5.x. Thanks!