adaptivetheme-8.x-3.x-dev/at_core/templates/views/views-view-table.html.twig
at_core/templates/views/views-view-table.html.twig
{# /** * @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. * * @see template_preprocess_views_view_table() */ #} {% set classes = [ 'table', 'views-table', 'views-view-table', 'cols-' ~ header|length, responsive ? 'responsive-enabled', sticky ? 'sticky-enabled', ] %} <table{{ attributes.addClass(classes) }}> {% if caption_needed %} {% if caption %} <caption class="table__caption caption">{{ caption }}</caption> {% else %} {{ title }} {% endif %} {% if (summary is not empty) or (description is not empty) %} <details class="table__details"> {% if summary is not empty %} <summary class="table__summary">{{ summary }}</summary> {% endif %} {% if description is not empty %} {{ description }} {% endif %} </details> {% endif %} </caption> {% endif %} {% if header %} <thead class="table__header"> <tr class="table__row"> {% for key, column in header %} {% if column.default_classes %} {% set column_classes = [ 'table__cell', '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 }}">{{ 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 }}">{{ column.content }}{{ column.sort_indicator }}</a> {%- else -%} {{- column.content }}{{ column.sort_indicator }} {%- endif -%} {%- endif -%} </th> {% endfor %} </tr> </thead> {% endif %} <tbody class="table__body"> {% for row in rows %} {% set row_classes = [ 'table__row', not no_striping ? cycle(['odd', 'even'], loop.index0), ] %} <tr{{ row.attributes.addClass(row_classes) }}> {% 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, 'table__cell') }}> {%- 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>