0

I'm new to Drupal so this might be a noobish question. I have a view called 'Category' where all posts are listed that belongs to the chosen category.

I would like to override the views-view-unformatted.html.twig as well as the views-view-field.html.twig which is working fine for other views.

When I enable the twig debug mode I see this at the top of the page:

<!-- FILE NAME SUGGESTIONS:
   * html--taxonomy--term--31.html.twig
   * html--taxonomy--term--%.html.twig
   * html--taxonomy--term.html.twig
   * html--taxonomy.html.twig
   x html.html.twig
-->

So I thought templates with the name

views-view-unformatted--categories.html.twig
views-view-fields--categories.html.twig

would do the job. Or being even more specific:

views-view-unformatted--categories--block-1.html.twig
views-view-fields--categories--block-1.html.twig

But these templates aren't used. I have also tried to use 'taxonomy--term' for the template names with no success. There is also no file name suggestion for these templates.

Can anyone please tell me how I can get it working or hint me to the right direction?

1 Answer 1

0

You either haven't rebuilt cache, or the page you're viewing isn't being generated by your Categories Views. It seems to be generated by the default Taxonomy term Views. Or you're viewing the wrong page :)

Views templates debug info is shown further down the source HTML, you won't find it at the top of the source page. Try looking below the main page heading in the source HTML, that's there the page views will start with their own templates.

This issue is also relevant:
Views file name suggestions often missing from Twig debugging

Especially the fifth comment there:
#5

Also:
[PP-3] Twig debug output does not display all suggestions when an array of theme hooks is passed to #theme

I haven't tried this module but it may be relevant:
Views Templates

1
  • 1
    It has been a taxonomy term view. So the correct file name is 'views-view-fields--taxonomy-term--page-1.html.twig'. Thanks for your hint and links. They really helped me out.
    – Simon
    Commented Jun 7, 2020 at 14:40

Your Answer

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

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