2

Is it possible to write a twig template for a specific view? I have a view with multiple blocks and I want all these blocks to look the same. But I am having trouble with my views actually knowing which theme to use. I am trying to inherit the block.html.twig template but none of my changes render.

I am also afraid that my changes will change every block not just the blocks for that view. How can i limit it to just my view?

0

Views in Drupal 8 has pretty much the same template options as in Drupal 7. If you are in doubt, what suggestions are offered, you should turn on twig debugging (settings in service.yml). You will get the suggestion output as HTML comments. Unlike in Drupal 7, Views in Drupal 8 does not have a button to see the templates files being used along with suggestions.

This might be added later as Drupal 8 is still in beta, at the time of this writing.

0

In addition to the advice offered by googletorp, this page on api.drupal.org has some examples:

https://api.drupal.org/api/drupal/core%21modules%21views%21views.theme.inc/group/views_templates/8

The Drupal 7 version for comparison:

https://api.drupal.org/api/views/theme!theme.inc/group/views_templates/7

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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