Closed (duplicate)
Project:
Drupal core
Version:
8.3.x-dev
Component:
taxonomy.module
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
15 Jul 2016 at 18:41 UTC
Updated:
5 Apr 2026 at 11:19 UTC
Jump to comment: Most recent, Most recent file

Comments
Comment #2
markconroy commentedAdding patch.
Comment #3
markconroy commentedChanging status to 'needs review'
Comment #4
markconroy commentedAdding author to commit message.
Comment #5
markconroy commentedComment #6
zerolab commentedAttaching a new patch that is sanitising the view mode, the same way
node_theme_suggestions_node()does.Comment #8
fabianx commentedRTBC, but core committers might ask for a test for this.
Comment #9
lauriiiFYI:
Comment #10
catchThis is very similar to #2766379: Add User view mode template suggestions, is it worth adding these centrally somewhere? Also we should look at #9.2 here as well.
Comment #11
lauriiiSorry folks, but I think this should be fixed here instead: #2270883: Automatically add theme hook suggestions for all entity types
Comment #12
markconroy commentedHi Laurii,
Agree. Would be better to have an auto-template generator and not try to fix these on an entity-by-entity basis. Happy to keep this closed.
Comment #13
enrico.sato commentedHi,
I reorder suggestions of #6 to have view_mode before and make suggestion more generic. I hope it will help!
Comment #14
enrico.sato commentedFixed #13, sorry
Comment #15
kbeck303 commentedI have tested the patch in comment #14 on drupal version 8.5.1 and the taxonomy term theme suggestions by view mode are displaying as excepted.
23 = tid
audience = vocabulary machine name
teaser = view mode
Comment #16
bdanin commentedconfirmed #14 works
Comment #17
kerby70 commentedHere's a workaround. Since the other task isn't complete, and this patch will not be going in.
Comment #18
vadim.jin commented#17 works for me. Thanks. Just add to the theme file and build any suggestion that you want.
Comment #19
shamsher_alam commented#17 Works for me. Thanks
Comment #20
alexpertsi commentedA different approach that you could follow is to create
taxonomy-term--services.html.twig (services = vocabulary machine name) for your vocabulary and check (if view_mode == 'teaser') the machine name of your view modes
Comment #21
stefan.kornHm, wondering why not getting #14 in. It's more than three years since the issue was opened and no more general solution seems to be in sight anytime soon. So why not having it the same way that node does it for taxonomy too, maybe with a ToDo hint to remove it if a more general solutions will finally be available.
Even taxonomy_theme_suggestions_taxonomy_term() is already there and only needs to be amended slightly, so the risk with this change seems to be very small.
And regarding tests: At this moment taxonomy module does no tests on the suggestions although suggestions are already created. But if only tests are hindering, than I could maybe provide them analogous to how node does it.
Kindly asking maintainers to maybe have a look on this issue again.
Comment #22
mlncn commentedAgreed with Stefan.
Contrib solution for now: Twig Template Suggester module
Comment #23
ptmkenny commentedFor those of us who are digging through issues trying to find what the latest status is, some work going on here: https://www.drupal.org/project/drupal/issues/2808481
Comment #24
jedgar1mx commented#17 works great 👍
Comment #25
amir jamshidi commented#17 Works for me. Thanks
Comment #26
swirt#14 works great.
It is nice that this has been closed as a duplicate of https://www.drupal.org/project/drupal/issues/2270883 BUT that issue has been bogged down since 2014. Similarly in https://www.drupal.org/project/drupal/issues/2808481 also stuck in a bog.
Comment #27
gaëlg#14 doesn't seem to apply on latest core but #17 is the way to go for now.
Comment #28
alex.bukach commentedRe-rolled #14.