views-view-table.html.twig
Same filename in this branch
- 10 core/profiles/demo_umami/themes/umami/templates/classy/views/views-view-table.html.twig
- 10 core/themes/olivero/templates/views/views-view-table.html.twig
- 10 core/themes/stable9/templates/views/views-view-table.html.twig
- 10 core/themes/starterkit_theme/templates/views/views-view-table.html.twig
- 10 core/modules/views/templates/views-view-table.html.twig
Same filename in other branches
- 9 core/profiles/demo_umami/themes/umami/templates/classy/views/views-view-table.html.twig
- 9 core/themes/olivero/templates/views/views-view-table.html.twig
- 9 core/themes/stable9/templates/views/views-view-table.html.twig
- 9 core/themes/seven/templates/classy/views/views-view-table.html.twig
- 9 core/themes/claro/templates/classy/views/views-view-table.html.twig
- 9 core/themes/bartik/templates/classy/views/views-view-table.html.twig
- 9 core/themes/stable/templates/views/views-view-table.html.twig
- 9 core/themes/starterkit_theme/templates/views/views-view-table.html.twig
- 9 core/themes/classy/templates/views/views-view-table.html.twig
- 9 core/modules/views/templates/views-view-table.html.twig
- 8.9.x core/profiles/demo_umami/themes/umami/templates/classy/views/views-view-table.html.twig
- 8.9.x core/themes/seven/templates/classy/views/views-view-table.html.twig
- 8.9.x core/themes/claro/templates/classy/views/views-view-table.html.twig
- 8.9.x core/themes/bartik/templates/classy/views/views-view-table.html.twig
- 8.9.x core/themes/stable/templates/views/views-view-table.html.twig
- 8.9.x core/themes/classy/templates/views/views-view-table.html.twig
- 8.9.x core/modules/views/templates/views-view-table.html.twig
- 11.x core/profiles/demo_umami/themes/umami/templates/classy/views/views-view-table.html.twig
- 11.x core/themes/olivero/templates/views/views-view-table.html.twig
- 11.x core/themes/stable9/templates/views/views-view-table.html.twig
- 11.x core/themes/claro/templates/views/views-view-table.html.twig
- 11.x core/themes/starterkit_theme/templates/views/views-view-table.html.twig
- 11.x core/modules/views/templates/views-view-table.html.twig
Theme override for displaying a view as a table.
Available variables:
- attributes: Remaining HTML attributes for the element.
- class: HTML classes that can be used to style contextually through CSS.
- title : The title of this group of rows.
- header: The table header columns.
- attributes: Remaining HTML attributes for the element.
- content: HTML classes to apply to each header cell, indexed by
the header's key.
- default_classes: A flag indicating whether default classes should be used.
- caption_needed: Is the caption tag needed.
- caption: The caption for this table.
- accessibility_description: Extended description for the table details.
- accessibility_summary: Summary for the table details.
- rows: Table row items. Rows are keyed by row number.
- attributes: HTML classes to apply to each row.
- columns: Row column items. Columns are keyed by column number.
- attributes: HTML classes to apply to each column.
- content: The column content.
- default_classes: A flag indicating whether default classes should be used.
- responsive: A flag indicating whether table is responsive.
- sticky: A flag indicating whether table header is sticky.
- summary_element: A render array with table summary information (if any).
See also
template_preprocess_views_view_table()
File
-
core/
themes/ claro/ templates/ views/ views-view-table.html.twig
View source
- {#
- /**
- * @file
- * Theme override for displaying a view as a table.
- *
- * Available variables:
- * - attributes: Remaining HTML attributes for the element.
- * - class: HTML classes that can be used to style contextually through CSS.
- * - title : The title of this group of rows.
- * - header: The table header columns.
- * - attributes: Remaining HTML attributes for the element.
- * - content: HTML classes to apply to each header cell, indexed by
- * the header's key.
- * - default_classes: A flag indicating whether default classes should be
- * used.
- * - caption_needed: Is the caption tag needed.
- * - caption: The caption for this table.
- * - accessibility_description: Extended description for the table details.
- * - accessibility_summary: Summary for the table details.
- * - rows: Table row items. Rows are keyed by row number.
- * - attributes: HTML classes to apply to each row.
- * - columns: Row column items. Columns are keyed by column number.
- * - attributes: HTML classes to apply to each column.
- * - content: The column content.
- * - default_classes: A flag indicating whether default classes should be
- * used.
- * - responsive: A flag indicating whether table is responsive.
- * - sticky: A flag indicating whether table header is sticky.
- * - summary_element: A render array with table summary information (if any).
- *
- * @see template_preprocess_views_view_table()
- */
- #}
- {%
- set classes = [
- 'views-table',
- 'views-view-table',
- 'cols-' ~ header|length,
- responsive ? 'responsive-enabled',
- sticky ? 'position-sticky sticky-header',
- ]
- %}
- <table{{ attributes.addClass(classes) }}>
- {% if caption_needed %}
- <caption>
- {% if caption %}
- {{ caption }}
- {% else %}
- {{ title }}
- {% endif %}
- {% if (summary_element is not empty) %}
- {{ summary_element }}
- {% endif %}
- </caption>
- {% endif %}
- {% if header %}
- <thead>
- <tr>
- {% for key, column in header %}
- {% if column.default_classes %}
- {%
- set column_classes = [
- 'views-field',
- 'views-field-' ~ fields[key],
- ]
- %}
- {% endif %}
- <th{{ column.attributes.addClass(column_classes).setAttribute('scope', 'col') }}>
- {%- if column.wrapper_element -%}
- <{{ column.wrapper_element }}>
- {%- if column.url -%}
- <a href="{{ column.url }}" title="{{ column.title }}" rel="nofollow">{{ column.content }}{{ column.sort_indicator }}</a>
- {%- else -%}
- {{ column.content }}{{ column.sort_indicator }}
- {%- endif -%}
- </{{ column.wrapper_element }}>
- {%- else -%}
- {%- if column.url -%}
- <a href="{{ column.url }}" title="{{ column.title }}" rel="nofollow">{{ column.content }}{{ column.sort_indicator }}</a>
- {%- else -%}
- {{- column.content }}{{ column.sort_indicator }}
- {%- endif -%}
- {%- endif -%}
- </th>
- {% endfor %}
- </tr>
- </thead>
- {% endif %}
- <tbody>
- {% for row in rows %}
- <tr{{ row.attributes }}>
- {% for key, column in row.columns %}
- {% if column.default_classes %}
- {%
- set column_classes = [
- 'views-field'
- ]
- %}
- {% for field in column.fields %}
- {% set column_classes = column_classes|merge(['views-field-' ~ field]) %}
- {% endfor %}
- {% endif %}
- <td{{ column.attributes.addClass(column_classes) }}>
- {%- if column.wrapper_element -%}
- <{{ column.wrapper_element }}>
- {% for content in column.content %}
- {{ content.separator }}{{ content.field_output }}
- {% endfor %}
- </{{ column.wrapper_element }}>
- {%- else -%}
- {% for content in column.content %}
- {{- content.separator }}{{ content.field_output -}}
- {% endfor %}
- {%- endif %}
- </td>
- {% endfor %}
- </tr>
- {% endfor %}
- </tbody>
- </table>
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.