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.

Comments

joachim created an issue. See original summary.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

jeroent’s picture

Issue tags: +Documentation, +Novice
jeroent’s picture

Issue tags: +Bug Smash Initiative
anagomes’s picture

Assigned: Unassigned » anagomes
anagomes’s picture

Assigned: anagomes » Unassigned
Status: Active » Needs review
StatusFileSize
new1010 bytes

This 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.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

elber’s picture

Status: Needs review » Reviewed & tested by the community

Hi I reviewed the patch and for me the new description managed to describe it correctly

murilohp’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new997 bytes
new1.77 KB

I think #14 needs a reroll to 9.5.x, I've made this one, moving back to NR.

murilohp’s picture

StatusFileSize
new997 bytes
new1.41 KB

Oooops, my bad, here's a new one.

andregp’s picture

Status: Needs review » Reviewed & tested by the community

The new text sounds reasonable for me.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

This 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 used as ordinarily the path will be set to the template directory in the module or theme's directory if

See...

        // Prepend the current theming path when none is set. This is required
        // for the default theme engine to know where the template lives.
        if (isset($result[$hook]['template']) && !isset($info['path'])) {
          $result[$hook]['path'] = $path . '/templates';
        }

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.

sophiavs’s picture

Assigned: Unassigned » sophiavs

Hi, i'll try to work on those changes specified in #20.

sophiavs’s picture

Assigned: sophiavs » Unassigned
Status: Needs work » Needs review
StatusFileSize
new1.25 KB

I 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

sophiavs’s picture

StatusFileSize
new1.35 KB
vinmayiswamy’s picture

I applied #23 patch against Drupal 9.5.x-dev and I can see that the text updated as suggested in #20.
Thanks @sophiavs

gquisini’s picture

Assigned: Unassigned » gquisini

I'll be reviewing

gquisini’s picture

Assigned: gquisini » Unassigned
Status: Needs review » Reviewed & tested by the community

The same as #24.

I applied the #23 patch and the hook_theme() docblock has the changes suggested in #20.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 23: 2867796-23.patch, failed testing. View results

ameymudras’s picture

Status: Needs work » Reviewed & tested by the community

Patch failed because of unrelated issue, marking this issue as RTBC again

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/lib/Drupal/Core/Render/theme.api.php
    @@ -1132,10 +1132,11 @@ function hook_page_bottom(array &$page_bottom) {
    + *     be set to the template directory in the module or theme's directory if
    

    It's the templates directory.

  2. +++ b/core/lib/Drupal/Core/Render/theme.api.php
    @@ -1132,10 +1132,11 @@ function hook_page_bottom(array &$page_bottom) {
    + *     include it here. This path should be relative to the subdirectory
    + *     'templates' of the path of the extension implementing hook_theme().
    

    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.

Ratan Priya’s picture

Status: Needs work » Needs review
StatusFileSize
new1.29 KB
new1.19 KB

@alexpott,
Made changes as per comment #29.
Needs review.

alexpott’s picture

Here's what I think the text should be:

 *   - path: If specified, overrides the path to the directory that contains the
 *     file to be used. This path should be relative to the Drupal root
 *     directory. If not provided, the path will be set to the module or theme's
 *     templates directory.

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.

alexpott’s picture

Status: Needs review » Needs work
ameymudras’s picture

Status: Needs work » Needs review
StatusFileSize
new1.24 KB
new1.22 KB

Changed the text as per your suggestion

vinmayiswamy’s picture

StatusFileSize
new309.34 KB

I applied #33 patch against Drupal 9.5.x-dev and the hook_theme() docblock has the changes suggested in #31.
Thanks @ameymudras

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

#33 made the change per @alexpott recommendation in #31

larowlan’s picture

Adding credits

larowlan’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

This 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

kunalgautam’s picture

Status: Needs work » Needs review
StatusFileSize
new130 KB

Patch for Drupal version 10.1.x

elber’s picture

Status: Needs review » Reviewed & tested by the community

Hi 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

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

The patch #39 contains lots of changes that are not supposed to be there. For example, it changes the root composer.json to install drush :)

elber’s picture

ok sorry I will work on it

elber’s picture

elber’s picture

Hi I couldn't work on that

kunalgautam’s picture

StatusFileSize
new1.24 KB

Thanks @alaxpott. It's my bad.
I have uploaded the updated patch.

kunalgautam’s picture

Status: Needs work » Needs review
elber’s picture

Status: Needs review » Reviewed & tested by the community

ok 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.

alexpott’s picture

Version: 10.1.x-dev » 10.0.x-dev
Status: Reviewed & tested by the community » Fixed
Issue tags: -Needs reroll

Committed 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.

  • alexpott committed f570135a on 10.1.x
    Issue #2867796 by murilohp, kkalashnikov, sophiavs, ameymudras, Ratan...

  • alexpott committed 85b728e2 on 10.0.x
    Issue #2867796 by murilohp, kkalashnikov, sophiavs, ameymudras, Ratan...
alexpott’s picture

Version: 10.0.x-dev » 9.5.x-dev

Found a 9.5.x version in #33 and committed that.

Committed 543019b and pushed to 9.5.x. Thanks!

  • alexpott committed 543019bb on 9.5.x
    Issue #2867796 by murilohp, kkalashnikov, sophiavs, ameymudras, Ratan...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.