You are here

views-view-responsive-grid.html.twig in Responsive Views Grid 8

Default theme implementation for views to display rows in a grid.

Available variables:

  • attributes: HTML attributes for the wrapping element.
  • title: The title of this group of rows.
  • view: The view object.
  • rows: The rendered view results.
  • options: The view plugin style options.
    • row_class_default: A flag indicating whether default classes should be used on rows.
    • col_class_default: A flag indicating whether default classes should be used on columns.
  • items: A list of grid items. Each item contains a list of rows or columns. The order in what comes first (row or column) depends on which alignment type is chosen (horizontal or vertical).

    • attributes: HTML attributes for each row or column.
    • content: A list of columns or rows. Each row or column contains:
      • attributes: HTML attributes for each row or column.
      • content: The row or column contents.

File

templates/views-view-responsive-grid.html.twig
View source
  1. {#
  2. /**
  3. * @file
  4. * Default theme implementation for views to display rows in a grid.
  5. *
  6. * Available variables:
  7. * - attributes: HTML attributes for the wrapping element.
  8. * - title: The title of this group of rows.
  9. * - view: The view object.
  10. * - rows: The rendered view results.
  11. * - options: The view plugin style options.
  12. * - row_class_default: A flag indicating whether default classes should be
  13. * used on rows.
  14. * - col_class_default: A flag indicating whether default classes should be
  15. * used on columns.
  16. * - items: A list of grid items. Each item contains a list of rows or columns.
  17. * The order in what comes first (row or column) depends on which alignment
  18. * type is chosen (horizontal or vertical).
  19. * - attributes: HTML attributes for each row or column.
  20. * - content: A list of columns or rows. Each row or column contains:
  21. * - attributes: HTML attributes for each row or column.
  22. * - content: The row or column contents.
  23. *
  24. * @see template_preprocess_views_view_grid()
  25. *
  26. * @ingroup themeable
  27. */
  28. #}
  29. {% set classes = [
  30. 'views-view-responsive-grid',
  31. options.alignment,
  32. 'cols-' ~ options.columns,
  33. 'clearfix',
  34. ] %}
  35. {% if options.row_class_default %}
  36. {% set row_classes = [
  37. 'views-row',
  38. options.alignment == 'horizontal' ? 'clearfix',
  39. ] %}
  40. {% endif %}
  41. {% if options.col_class_default %}
  42. {% set col_classes = [
  43. 'views-col',
  44. options.alignment == 'vertical' ? 'clearfix',
  45. ] %}
  46. {% endif %}
  47. {% if title %}
  48. <h3>{{ title }}</h3>
  49. {% endif %}
  50. <div{{ attributes.addClass(classes) }}>
  51. {% if options.alignment == 'horizontal' %}
  52. {% for row in items %}
  53. <div{{ row.attributes.addClass(row_classes, options.row_class_default ? 'row-' ~ loop.index) }}>
  54. {% for column in row.content %}
  55. <div{{ column.attributes.addClass(col_classes, options.col_class_default ? 'col-' ~ loop.index) }}>
  56. {{- column.content -}}
  57. </div>
  58. {% endfor %}
  59. </div>
  60. {% endfor %}
  61. {% else %}
  62. {% for column in items %}
  63. <div{{ column.attributes.addClass(col_classes, options.col_class_default ? 'col-' ~ loop.index) }}>
  64. {% for row in column.content %}
  65. <div{{ row.attributes.addClass(row_classes, options.row_class_default ? 'row-' ~ loop.index) }}>
  66. {{- row.content -}}
  67. </div>
  68. {% endfor %}
  69. </div>
  70. {% endfor %}
  71. {% endif %}
  72. </div>