You are here

views-summarize-view-summarized-table.html.twig in Views Summarize 1.1.x

Default theme implementation 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).
  • fields: An array of CSS IDs to use for each field id.
  • summarized: The summarized data in an array, keyed by field machine name.

File

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