I have a block view with an image field.
I know how to theme this field :
views-view-fields—my-images.html.twig
How can I wrap this loop with an element like : <div class="slider-article">
I’ve tried different solutions without success.
Theme the block twig template :
If I use block--views-block--slider-images.html.twig
Of course it doesn’t work because there is no possibility to theme the field inside this twig template.
I’ve tried to add my wrapper in the header and footer option in the view but even if it works, it is not perfect since I need to have a better control on the html (I’m doing a slick slider, I know there is a module but I don’t want to use it).
I’m trying to do something I can do in node :
In node—lorem.html.twig
:
{{ content.field_my_images }}
In field--field-my_images.html.twig
<div class="slider-article">
{% for item in items %}
<div>
{{ item.content }}
</div>
{% endfor %}
</div>
I’ve also checked all the "rewrite results" options in view but didn’t manage to add a wrapper.
I prefer a solution where I can create my custom html strcucture like the above example with a loop.
EDIT
Here is the HTML structure I need :
<!-- How can I add this wrapper ? -->
<div class="slider-article">
<!-- views-view-fields--[view-name]--[machine-name].html.twig starts here ! -->
<div>your content</div>
<div>your content</div>
<div>your content</div>
<!-- END OF views-view-fields--[view-name]--[machine-name].html.twig -->
</div>