diff --git a/core/includes/theme.inc b/core/includes/theme.inc index f91c5cc..6056350 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1549,6 +1549,7 @@ function template_preprocess_table(&$variables) { $responsive_classes = array(); // Format the table header: + $ts =array(); if (!empty($variables['header'])) { $ts = tablesort_init($variables['header']); @@ -1599,13 +1600,11 @@ function template_preprocess_table(&$variables) { // Format the table footer: if (!empty($variables['footer'])) { - $ts = tablesort_init($variables['footer']); foreach ($variables['footer'] as $col_key => $cell) { if (!is_array($cell)) { $cell_content = $cell; $cell_attributes = new Attribute(); - $is_footer = TRUE; } else { $cell_content = ''; @@ -1614,7 +1613,6 @@ function template_preprocess_table(&$variables) { unset($cell['data']); } // Flag the cell as a footer or not and remove the flag. - $is_footer = isset($cell['footer']) ? $cell['footer'] : TRUE; unset($cell['footer']); // Track responsive classes for each column as needed. Only the footer @@ -1633,10 +1631,6 @@ function template_preprocess_table(&$variables) { if (is_array($cell_content)) { $cell_content = drupal_render($cell_content); } - - tablesort_footer($cell_content, $cell, $variables['footer'], $ts); - - // tablesort_footer() removes the 'sort' and 'field' keys. $cell_attributes = new Attribute($cell); } $variables['footer'][$col_key] = array(); diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php index 6b9c5ef..80f5f90 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/TableTest.php @@ -86,15 +86,24 @@ function testThemeTableWithEmptyMessage() { 'colspan' => 2, ), ); + $footer = array( + 'Footer 1', + array( + 'data' => 'Footer 2', + 'colspan' => 2, + ), + ); $table = array( '#type' => 'table', '#header' => $header, + '#footer' => $footer, '#rows' => array(), '#empty' => 'Empty row.', ); $this->render($table); $this->removeWhiteSpace(); $this->assertRaw('Header 1Header 2', 'Table header found.'); + $this->assertRaw('Footer 1Footer 2', 'Table footer found.'); $this->assertRaw('Empty row.', 'Colspan on #empty row found.'); } diff --git a/core/modules/system/templates/table.html.twig b/core/modules/system/templates/table.html.twig index 6aec2b6..48b0c12 100644 --- a/core/modules/system/templates/table.html.twig +++ b/core/modules/system/templates/table.html.twig @@ -40,7 +40,6 @@ {% if caption %} {{ caption }} {% endif %} - {% for colgroup in colgroups %} {% if colgroup.cols %} @@ -52,7 +51,6 @@ {% endif %} {% endfor %} - {% if header %} @@ -64,7 +62,17 @@ {% endif %} - + {% if footer %} + + + {% for cell in footer %} + <{{ cell.tag }}{{ cell.attributes }}> + {{- cell.content -}} + + {% endfor %} + + + {% endif %} {% if rows %} {% for row in rows %} @@ -78,16 +86,4 @@ {% endfor %} {% endif %} - - {% if header %} - - - {% for cell in header %} - <{{ cell.tag }}{{ cell.attributes }}> - {{- cell.content -}} - - {% endfor %} - - - {% endif %}