Is it posible to print all view field direct in views-view-fields.html.twig and sciping to use views-view-field.html.twig?

In my blog view I have a lot views-view-field.html.twig for every field type and this is just one view.

So is this posible and is this recomend?


Yes, that is possible, this is the most basic fields twig:

{% for field in fields -%}
    {{ field.content }}
{%- endfor %}

Then you loose most field configuration from views and can put in your own html structure.

You don't need to skip the field twigs for single fields, simply delete you own twigs and let the core twigs take over again.

  • Ok. I understend. And if I want to have my own html structure, can I write somethink like {{ field.field_image.content }} Would drupal know to print only image field and not other field who are add in view? – SakaSerbia Apr 4 '16 at 13:05
  • 1
    If you only want to print single fields like {{ fields.field1 }} and don't want to print all fields, then you don't need the {% for %} loop at all. – 4k4 Apr 4 '16 at 13:44
  • Thank you a lot. With you help, experimentally and this article redcrackle.com/blog/drupal-8/theme-views-templates I learn.. :) – SakaSerbia Apr 4 '16 at 15:19

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.