views-view-grid.html.twig

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

Available variables:

  • attributes: HTML attributes for the table element.
  • title: The title of this group of rows.
  • rows: A list of rows. Each row contains a list of columns.
  • row_classes: HTML classes for each row including the row number and first or last.
  • column_classes: HTML classes for each column including the row number and first or last.

See also

template_preprocess()

template_preprocess_views_view_grid()

File

drupal/core/modules/views/templates/views-view-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 table element.
  8. * - title: The title of this group of rows.
  9. * - rows: A list of rows. Each row contains a list of columns.
  10. * - row_classes: HTML classes for each row including the row number and first
  11. * or last.
  12. * - column_classes: HTML classes for each column including the row number and
  13. * first or last.
  14. *
  15. * @see template_preprocess()
  16. * @see template_preprocess_views_view_grid()
  17. *
  18. * @ingroup themeable
  19. */
  20. #}
  21. {% if title %}
  22. <h3>{{ title }}</h3>
  23. {% endif %}
  24. <table{{ attributes }}>
  25. <tbody>
  26. {% for row_number, columns in rows %}
  27. <tr{{ row_classes[row_number] }}>
  28. {% for column_number, item in columns %}
  29. <td{{ column_classes[row_number][column_number] }}>
  30. {{ item }}
  31. </td>
  32. {% endfor %}
  33. </tr>
  34. {% endfor %}
  35. </tbody>
  36. </table>

Related topics