annotate core/themes/stable/templates/views/views-view-table.html.twig @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 4c8ae668cc8c
children
rev   line source
Chris@0 1 {#
Chris@0 2 /**
Chris@0 3 * @file
Chris@0 4 * Theme override for displaying a view as a table.
Chris@0 5 *
Chris@0 6 * Available variables:
Chris@0 7 * - attributes: Remaining HTML attributes for the element.
Chris@0 8 * - class: HTML classes that can be used to style contextually through CSS.
Chris@0 9 * - title : The title of this group of rows.
Chris@0 10 * - header: The table header columns.
Chris@0 11 * - attributes: Remaining HTML attributes for the element.
Chris@0 12 * - content: HTML classes to apply to each header cell, indexed by
Chris@0 13 * the header's key.
Chris@0 14 * - default_classes: A flag indicating whether default classes should be
Chris@0 15 * used.
Chris@0 16 * - caption_needed: Is the caption tag needed.
Chris@0 17 * - caption: The caption for this table.
Chris@0 18 * - accessibility_description: Extended description for the table details.
Chris@0 19 * - accessibility_summary: Summary for the table details.
Chris@0 20 * - rows: Table row items. Rows are keyed by row number.
Chris@0 21 * - attributes: HTML classes to apply to each row.
Chris@0 22 * - columns: Row column items. Columns are keyed by column number.
Chris@0 23 * - attributes: HTML classes to apply to each column.
Chris@0 24 * - content: The column content.
Chris@0 25 * - default_classes: A flag indicating whether default classes should be
Chris@0 26 * used.
Chris@0 27 * - responsive: A flag indicating whether table is responsive.
Chris@0 28 * - sticky: A flag indicating whether table header is sticky.
Chris@0 29 *
Chris@0 30 * @see template_preprocess_views_view_table()
Chris@0 31 */
Chris@0 32 #}
Chris@0 33 {%
Chris@0 34 set classes = [
Chris@0 35 'cols-' ~ header|length,
Chris@0 36 responsive ? 'responsive-enabled',
Chris@0 37 sticky ? 'sticky-enabled',
Chris@0 38 ]
Chris@0 39 %}
Chris@0 40 <table{{ attributes.addClass(classes) }}>
Chris@0 41 {% if caption_needed %}
Chris@0 42 <caption>
Chris@0 43 {% if caption %}
Chris@0 44 {{ caption }}
Chris@0 45 {% else %}
Chris@0 46 {{ title }}
Chris@0 47 {% endif %}
Chris@0 48 {% if (summary is not empty) or (description is not empty) %}
Chris@0 49 <details>
Chris@0 50 {% if summary is not empty %}
Chris@0 51 <summary>{{ summary }}</summary>
Chris@0 52 {% endif %}
Chris@0 53 {% if description is not empty %}
Chris@0 54 {{ description }}
Chris@0 55 {% endif %}
Chris@0 56 </details>
Chris@0 57 {% endif %}
Chris@0 58 </caption>
Chris@0 59 {% endif %}
Chris@0 60 {% if header %}
Chris@0 61 <thead>
Chris@0 62 <tr>
Chris@0 63 {% for key, column in header %}
Chris@0 64 {% if column.default_classes %}
Chris@0 65 {%
Chris@0 66 set column_classes = [
Chris@0 67 'views-field',
Chris@0 68 'views-field-' ~ fields[key],
Chris@0 69 ]
Chris@0 70 %}
Chris@0 71 {% endif %}
Chris@0 72 <th{{ column.attributes.addClass(column_classes).setAttribute('scope', 'col') }}>
Chris@0 73 {%- if column.wrapper_element -%}
Chris@0 74 <{{ column.wrapper_element }}>
Chris@0 75 {%- if column.url -%}
Chris@0 76 <a href="{{ column.url }}" title="{{ column.title }}">{{ column.content }}{{ column.sort_indicator }}</a>
Chris@0 77 {%- else -%}
Chris@0 78 {{ column.content }}{{ column.sort_indicator }}
Chris@0 79 {%- endif -%}
Chris@0 80 </{{ column.wrapper_element }}>
Chris@0 81 {%- else -%}
Chris@0 82 {%- if column.url -%}
Chris@0 83 <a href="{{ column.url }}" title="{{ column.title }}">{{ column.content }}{{ column.sort_indicator }}</a>
Chris@0 84 {%- else -%}
Chris@0 85 {{- column.content }}{{ column.sort_indicator }}
Chris@0 86 {%- endif -%}
Chris@0 87 {%- endif -%}
Chris@0 88 </th>
Chris@0 89 {% endfor %}
Chris@0 90 </tr>
Chris@0 91 </thead>
Chris@0 92 {% endif %}
Chris@0 93 <tbody>
Chris@0 94 {% for row in rows %}
Chris@0 95 <tr{{ row.attributes }}>
Chris@0 96 {% for key, column in row.columns %}
Chris@0 97 {% if column.default_classes %}
Chris@0 98 {%
Chris@0 99 set column_classes = [
Chris@0 100 'views-field'
Chris@0 101 ]
Chris@0 102 %}
Chris@0 103 {% for field in column.fields %}
Chris@0 104 {% set column_classes = column_classes|merge(['views-field-' ~ field]) %}
Chris@0 105 {% endfor %}
Chris@0 106 {% endif %}
Chris@0 107 <td{{ column.attributes.addClass(column_classes) }}>
Chris@0 108 {%- if column.wrapper_element -%}
Chris@0 109 <{{ column.wrapper_element }}>
Chris@0 110 {% for content in column.content %}
Chris@0 111 {{ content.separator }}{{ content.field_output }}
Chris@0 112 {% endfor %}
Chris@0 113 </{{ column.wrapper_element }}>
Chris@0 114 {%- else -%}
Chris@0 115 {% for content in column.content %}
Chris@0 116 {{- content.separator }}{{ content.field_output -}}
Chris@0 117 {% endfor %}
Chris@0 118 {%- endif %}
Chris@0 119 </td>
Chris@0 120 {% endfor %}
Chris@0 121 </tr>
Chris@0 122 {% endfor %}
Chris@0 123 </tbody>
Chris@0 124 </table>