0

I have so much fields in a content like "title", "field_image", "field_description", and i use a view for create a block and put it on my front page...

I will make a slider with a jquery plugin (jssor slider), i need use the structure of jssor slider. then in my view, i use "views-view-fields--[name_machine]--block.html.twig" for print individual fields. but the file "views-view-fields..." print for each content, run all code on this file,and i need to put the initial containers of this plugin only once, and the code of the images several times.

I try to put the initial containers of the plugin in the "page.html.twig" but when i print the block with the "views-view-fields..." inside he puts a lot of code and many labels and containers that I do not need and the plugin stops working. let me show the files.

my page.html.twig {# Header #} {% if page.banner_front %}

    <div id="jssor_1">
      <!-- Loading Screen -->
      <div data-u="loading" class="jssorl-009-spin">
          <img src="/images/spin.svg" />
      </div>
      <div data-u="slides"> 

        {% block banner_front %}
            {{ page.banner_front }}
        {% endblock %}

      </div>       
     </div>

then my views-view-fields--banner--block.html.twig:

           <div data-b="0">
                <img data-u="image" src="{{ fields.field_imagen.content }}"/>
                <div class="caption-banner" data-u="caption" data-t="0">
                    <div class="title-banner">
                        {% if fields.title.content %}
                            {{ fields.title.content }}
                        {% endif %}
                    </div>
                    <div class="description-banner">
                        {% if fields.banner_description.content %}
                            {{ fields.banner_description.content }}
                        {% endif %}
                    </div>
                    {% if fields.field_url.content %}
                        <a href="#" target="_blan">   
                            <div class="btn-ver">Ver más</div>
                        </a>
                    {% endif %}
                </div>
            </div>

to work correctly, the label <div data-b = '0'> must be left of the label <div data-u = 'slides'>, but when the region is printed the system prints many labels and containers that damage the structure of the slider.

On Drupal 7 i used inside of the foreach the code of the images, and outside the inicial structure, and works well but now, i dont know how to this.

Thanks a lot.

4
  • the "views-view-fields..." inside he puts a lot of code and many labels and containers that I do not need to remove this markup follow my answer here
    – No Sssweat
    Commented Oct 30, 2018 at 22:07
  • if you work with Format:Unformatted list try to override the views-view-unformatted.html.twig you will have the ability to add class to parent or inside each row
    – berramou
    Commented Oct 30, 2018 at 22:19
  • so glad that help.
    – berramou
    Commented Oct 31, 2018 at 15:25
  • I have poste it as answer if someone need it in the future.
    – berramou
    Commented Oct 31, 2018 at 15:31

1 Answer 1

0

If you work with Format:Unformatted list try to override the views-view-unformatted.html.twig, you will have the ability to add class to parent or inside each row.

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.