You are here

views-view-footable.html.twig in FooTable 8.2

Same filename and directory in other branches
  1. 8 templates/views-view-footable.html.twig

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.

File

templates/views-view-footable.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. *
  30. * @see template_preprocess_views_view_table()
  31. *
  32. * @ingroup themeable
  33. */
  34. #}
  35. <table{{ attributes.addClass(classes) }}>
  36. {% if caption_needed %}
  37. <caption>
  38. {% if caption %}
  39. {{ caption }}
  40. {% else %}
  41. {{ title }}
  42. {% endif %}
  43. {% if (summary is not empty) or (description is not empty) %}
  44. <details>
  45. {% if summary is not empty %}
  46. <summary>{{ summary }}</summary>
  47. {% endif %}
  48. {% if description is not empty %}
  49. {{ description }}
  50. {% endif %}
  51. </details>
  52. {% endif %}
  53. </caption>
  54. {% endif %}
  55. {% if header %}
  56. <thead>
  57. <tr>
  58. {% for key, column in header %}
  59. {% if column.default_classes %}
  60. {%
  61. set column_classes = [
  62. 'views-field',
  63. 'views-field-' ~ fields[key],
  64. ]
  65. %}
  66. {% endif %}
  67. <th{{ column.attributes.addClass(column_classes).setAttribute('scope', 'col') }}>
  68. {%- if column.wrapper_element -%}
  69. <{{ column.wrapper_element }}>
  70. {%- if column.url -%}
  71. <a href="{{ column.url }}" title="{{ column.title }}">{{ column.content }}{{ column.sort_indicator }}</a>
  72. {%- else -%}
  73. {{ column.content }}{{ column.sort_indicator }}
  74. {%- endif -%}
  75. </{{ column.wrapper_element }}>
  76. {%- else -%}
  77. {%- if column.url -%}
  78. <a href="{{ column.url }}" title="{{ column.title }}">{{ column.content }}{{ column.sort_indicator }}</a>
  79. {%- else -%}
  80. {{- column.content }}{{ column.sort_indicator }}
  81. {%- endif -%}
  82. {%- endif -%}
  83. </th>
  84. {% endfor %}
  85. </tr>
  86. </thead>
  87. {% endif %}
  88. <tbody>
  89. {% for row in rows %}
  90. <tr{{ row.attributes }}>
  91. {% for key, column in row.columns %}
  92. {% if column.default_classes %}
  93. {%
  94. set column_classes = [
  95. 'views-field'
  96. ]
  97. %}
  98. {% for field in column.fields %}
  99. {% set column_classes = column_classes|merge(['views-field-' ~ field]) %}
  100. {% endfor %}
  101. {% endif %}
  102. <td{{ column.attributes.addClass(column_classes) }}>
  103. {%- if column.wrapper_element -%}
  104. <{{ column.wrapper_element }}>
  105. {% for content in column.content %}
  106. {{ content.separator }}{{ content.field_output }}
  107. {% endfor %}
  108. </{{ column.wrapper_element }}>
  109. {%- else -%}
  110. {% for content in column.content %}
  111. {{- content.separator }}{{ content.field_output -}}
  112. {% endfor %}
  113. {%- endif %}
  114. </td>
  115. {% endfor %}
  116. </tr>
  117. {% endfor %}
  118. </tbody>
  119. </table>