You are here

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

Same filename and directory in other branches
  1. 8 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
  • use_additional_wrapper: A flag for additional 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. * - use_additional_wrapper: A flag for additional wrapper usage
  18. *
  19. * @ingroup themeable
  20. */
  21. #}
  22. {% if use_wrapper %}
  23. {% if use_additional_wrapper %}
  24. <div class="views-rows-wrapper">
  25. {% endif %}
  26. {% set k = 0 %}
  27. {% set is_wrapped_once = 0 %}
  28. {% for row in rows %}
  29. {% set k = k + 1 %}
  30. {% if (k == 1) and (is_wrapped_once == 0) %}
  31. {% if attribute_name %}
  32. <{{ element_type }} {{ attribute_type }} ="{{ attribute_name }}">
  33. {% else %}
  34. <{{ element_type }}>
  35. {% endif %}
  36. <div{{ row.attributes }}>
  37. {{ row.content }}
  38. </div>
  39. {% else %}
  40. <div{{ row.attributes }}>
  41. {{ row.content }}
  42. </div>
  43. {% endif %}
  44. {% if (loop.index is divisible by(rows_number)) or ((loop.index == loop.last) and (k < rows_number)) %}
  45. {% if is_wrapped_once == 0 %}
  46. </{{ element_type }}>
  47. {% endif %}
  48. {% endif %}
  49. {% if (k == rows_number) %}
  50. {% set k = 0 %}
  51. {% if (wrap_method == 1) %}
  52. {% set is_wrapped_once = 1 %}
  53. {% endif %}
  54. {% endif %}
  55. {% endfor %}
  56. {% if use_additional_wrapper %}
  57. </div>
  58. {% endif %}
  59. {% else %}
  60. {% for row in rows %}
  61. <div{{ row.attributes }}>
  62. {{ row.content }}
  63. </div>
  64. {% endfor %}
  65. {% endif %}