You are here

views-view-table.html.twig in Open Social 8.4

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.

  • 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.
  • responsive: Whether or not to use the .table-responsive wrapper.
  • 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.
  • bordered: Flag indicating whether or not the table should be bordered.
  • condensed: Flag indicating whether or not the table should be condensed.
  • hover: Flag indicating whether or not table rows should be hoverable.
  • striped: Flag indicating whether or not table rows should be striped.
  • responsive: Flag indicating whether or not the table should be wrapped to be responsive (using the Bootstrap Framework .table-responsive wrapper).

File

themes/socialbase/templates/views/views-view-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. * - caption_needed: Is the caption tag needed.
  15. * - caption: The caption for this table.
  16. * - accessibility_description: Extended description for the table details.
  17. * - accessibility_summary: Summary for the table details.
  18. * - responsive: Whether or not to use the .table-responsive wrapper.
  19. * - rows: Table row items. Rows are keyed by row number.
  20. * - attributes: HTML classes to apply to each row.
  21. * - columns: Row column items. Columns are keyed by column number.
  22. * - attributes: HTML classes to apply to each column.
  23. * - content: The column content.
  24. * - bordered: Flag indicating whether or not the table should be bordered.
  25. * - condensed: Flag indicating whether or not the table should be condensed.
  26. * - hover: Flag indicating whether or not table rows should be hoverable.
  27. * - striped: Flag indicating whether or not table rows should be striped.
  28. * - responsive: Flag indicating whether or not the table should be wrapped to
  29. * be responsive (using the Bootstrap Framework .table-responsive wrapper).
  30. *
  31. * @ingroup templates
  32. *
  33. * @see template_preprocess_views_view_table()
  34. */
  35. #}
  36. {%
  37. set classes = [
  38. 'table',
  39. 'table-hover',
  40. 'table-striped',
  41. sticky ? 'sticky-enabled',
  42. ]
  43. %}
  44. <div class="card">
  45. <div class="table-responsive card__block--table">
  46. <table{{ attributes.addClass(classes) }}>
  47. {% if caption_needed %}
  48. <caption>
  49. {% if caption %}
  50. {{ caption }}
  51. {% else %}
  52. {{ title }}
  53. {% endif %}
  54. {% if (summary is not empty) or (description is not empty) %}
  55. <details>
  56. {% if summary is not empty %}
  57. <summary>{{ summary }}</summary>
  58. {% endif %}
  59. {% if description is not empty %}
  60. {{ description }}
  61. {% endif %}
  62. </details>
  63. {% endif %}
  64. </caption>
  65. {% endif %}
  66. {% if header %}
  67. <thead>
  68. <tr>
  69. {% for key, column in header %}
  70. {% if column.default_classes %}
  71. {%
  72. set column_classes = [
  73. 'views-field',
  74. 'views-field-' ~ fields[key],
  75. ]
  76. %}
  77. {% endif %}
  78. <th{{ column.attributes.addClass(column_classes).setAttribute('scope', 'col') }}>
  79. {%- if column.wrapper_element -%}
  80. <{{ column.wrapper_element }}>
  81. {%- if column.url -%}
  82. <a href="{{ column.url }}" title="{{ column.title }}">{{ column.content }}{{ column.sort_indicator }}</a>
  83. {%- else -%}
  84. {{ column.content }}{{ column.sort_indicator }}
  85. {%- endif -%}
  86. </{{ column.wrapper_element }}>
  87. {%- else -%}
  88. {%- if column.url -%}
  89. <a href="{{ column.url }}" title="{{ column.title }}">{{ column.content }}{{ column.sort_indicator }}</a>
  90. {%- else -%}
  91. {{- column.content }}{{ column.sort_indicator }}
  92. {%- endif -%}
  93. {%- endif -%}
  94. </th>
  95. {% endfor %}
  96. </tr>
  97. </thead>
  98. {% endif %}
  99. <tbody>
  100. {% for row in rows %}
  101. <tr{{ row.attributes }}>
  102. {% for key, column in row.columns %}
  103. {% if column.default_classes %}
  104. {% set column_classes = [ 'views-field' ] %}
  105. {% for field in column.fields %}
  106. {% set column_classes = column_classes|merge(['views-field-' ~ field]) %}
  107. {% endfor %}
  108. {% endif %}
  109. <td{{ column.attributes.addClass(column_classes) }}>
  110. {%- if column.wrapper_element -%}
  111. <{{ column.wrapper_element }}>
  112. {% for content in column.content %}
  113. {{ content.separator }}{{ content.field_output }}
  114. {% endfor %}
  115. </{{ column.wrapper_element }}>
  116. {%- else -%}
  117. {% for content in column.content %}
  118. {{- content.separator }}{{ content.field_output -}}
  119. {% endfor %}
  120. {%- endif %}
  121. </td>
  122. {% endfor %}
  123. </tr>
  124. {% endfor %}
  125. </tbody>
  126. </table>
  127. </div>
  128. </div>