You are here

views-rows-wrapper.html.twig in Views Rows Wrapper 8

Same filename and directory in other branches
  1. 8.2 templates/views-rows-wrapper.html.twig

Default theme implementation to output a views rows wrapper display style plugin.

Available variables:

  • rows: A list of the view's row items.

    • attributes: The row's HTML attributes.
    • content: The row's content.
  • view: The view object.
  • element_type: Wrapper element type
  • attribute_type: Attribute type of the selected wrapper element
  • attribute_name: Name of the selected attribute.
  • rows_number: A number of rows to wrap
  • wrap_method: 0 - Apply to all items, 1 - Wrap once.
  • use_wrapper: A flag for wrapper usage

File

templates/views-rows-wrapper.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Default theme implementation to output a views rows wrapper display style plugin.
  5. *
  6. * Available variables:
  7. * - rows: A list of the view's row items.
  8. * - attributes: The row's HTML attributes.
  9. * - content: The row's content.
  10. * - view: The view object.
  11. * - element_type: Wrapper element type
  12. * - attribute_type: Attribute type of the selected wrapper element
  13. * - attribute_name: Name of the selected attribute.
  14. * - rows_number: A number of rows to wrap
  15. * - wrap_method: 0 - Apply to all items, 1 - Wrap once.
  16. * - use_wrapper: A flag for wrapper usage
  17. *
  18. * @ingroup themeable
  19. */
  20. #}
  21. {% if use_wrapper %}
  22. <div class="views-rows-wrapper">
  23. {% set k = 0 %}
  24. {% set is_wrapped_once = 0 %}
  25. {% for row in rows %}
  26. {% set k = k + 1 %}
  27. {% if (k == 1) and (is_wrapped_once == 0) %}
  28. {% if attribute_name %}
  29. <{{ element_type }} {{ attribute_type }} ="{{ attribute_name }}">
  30. {% else %}
  31. <{{ element_type }}>
  32. {% endif %}
  33. <div{{ row.attributes }}>
  34. {{ row.content }}
  35. </div>
  36. {% else %}
  37. <div{{ row.attributes }}>
  38. {{ row.content }}
  39. </div>
  40. {% endif %}
  41. {% if (loop.index is divisible by(rows_number)) or ((loop.index == loop.last) and (k < rows_number)) %}
  42. {% if is_wrapped_once == 0 %}
  43. </{{ element_type }}>
  44. {% endif %}
  45. {% endif %}
  46. {% if (k == rows_number) %}
  47. {% set k = 0 %}
  48. {% if (wrap_method == 1) %}
  49. {% set is_wrapped_once = 1 %}
  50. {% endif %}
  51. {% endif %}
  52. {% endfor %}
  53. </div>
  54. {% else %}
  55. {% for row in rows %}
  56. <div{{ row.attributes }}>
  57. {{ row.content }}
  58. </div>
  59. {% endfor %}
  60. {% endif %}