2

I want to override file-upload-help.html.twig located in core\themes\classy\templates\content-edit. This template displays help text for file upload fields on node edit pages.

If I inspect the file upload help text on a page, above it I see (in debug mode):

BEGIN OUTPUT from 'core/themes/classy/templates/content-edit/file-upload-help.html.twig'

There is no FILE NAME SUGGESTIONS line before or after this line.

My site sub-themes the bootstrap theme.

I tried simply putting a file-upload-help.html.twig file in my sub-theme's templates folder, but it was ignored. Not surprising since I'm sub-theming bootstrap, not classy.

Is there a way to add more information to the theme.info.yml file to override classy templates as well? Or some other way to override the template? If I simply edit the file-upload-help.html.twig file within the classy theme folder, it works, but of course that's bad behavior.

3
  • 2
    Did you rebuild cache? Are you using an admin theme to create/edit content?
    – prkos
    Feb 22, 2019 at 23:51
  • The template should be picked up by the theme in use. You need to rebuild your caches after you added new templates to your theme. - Alternatively (as this template doesn't do much on its own), you can also implement hook_preprocess_file_upload_help(&$variables) to modify the description of the file upload element to your liking. Feb 23, 2019 at 4:26
  • @prkos Your admin theme question sparked the needed understanding. I realized I need to sub-theme the Seven admin theme and then select that sub-theme as the Administration theme at the bottom of the Appearance page. Thanks! So, shall I answer my own question thanks to your help, or do you want to answer so I can upvote your answer? P.S. to both commenters: Thanks, I had rebuilt the cache. Feb 23, 2019 at 22:33

1 Answer 1

3

As discovered through the comments discussion the answer in this case is to place the template into the admin subtheme (not the default theme).

When adding new templates to your subtheme it's important to be aware of the fact that there are usually two active themes in any Drupal site: the default one for "front-end" and an admin one for the "back-end" side.

There is also a part of the site that is ambiguous about whether it falls under "front-" or "back-end", and that is Editing content pages.

There is a setting under Appearance that controls which theme should be used for editing content. When adding a template for content-editing pages it's important to double-check which theme is chosen there to know which theme to add the template to.

As always, don't modify the contributed themes, instead add a subtheme that extends them and add the template there. Then adjust the Appearance settings to use the subtheme.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.