views-view-grid.html.twig
Same filename in this branch
Same filename in other branches
- 9 core/themes/olivero/templates/views/views-view-grid.html.twig
- 9 core/themes/stable9/templates/views/views-view-grid.html.twig
- 9 core/themes/stable/templates/views/views-view-grid.html.twig
- 9 core/themes/starterkit_theme/templates/views/views-view-grid.html.twig
- 9 core/themes/classy/templates/views/views-view-grid.html.twig
- 9 core/modules/views/templates/views-view-grid.html.twig
- 8.9.x core/themes/stable/templates/views/views-view-grid.html.twig
- 8.9.x core/themes/classy/templates/views/views-view-grid.html.twig
- 8.9.x core/modules/views/templates/views-view-grid.html.twig
- 11.x core/themes/olivero/templates/views/views-view-grid.html.twig
- 11.x core/themes/stable9/templates/views/views-view-grid.html.twig
- 11.x core/themes/starterkit_theme/templates/views/views-view-grid.html.twig
- 11.x core/modules/views/templates/views-view-grid.html.twig
Theme override 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.
See also
template_preprocess_views_view_grid()
File
-
core/
themes/ olivero/ templates/ views/ views-view-grid.html.twig
View source
- {#
- /**
- * @file
- * Theme override 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.
- *
- * @see template_preprocess_views_view_grid()
- */
- #}
- {{ attach_library('olivero/layout-views-grid') }}
-
- {%
- set classes = [
- 'views-view-grid',
- 'views-view-grid--' ~ options.alignment,
- ]
- %}
-
- {% if title %}
- <h3>{{ title }}</h3>
- {% endif %}
- <div{{ attributes.addClass(classes).setAttribute('style', '--views-grid--column-count: ' ~ options.columns) }}>
- {% for row in items %}
- {% for item in row.content %}
- <div class="views-view-grid__item">
- <div class="views-view-grid__item-inner">
- {{- item.content -}}
- </div>
- </div>
- {% endfor %}
- {% endfor %}
- </div>
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.