diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 303db67..44c96fe 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1358,6 +1358,7 @@ function template_preprocess_table(&$variables) { $variables[$section][$row_key]['cells'][$col_key]['tag'] = $is_header ? 'th' : 'td'; $variables[$section][$row_key]['cells'][$col_key]['attributes'] = new Attribute($cell_attributes); $variables[$section][$row_key]['cells'][$col_key]['content'] = $cell_content; + $variables[$section][$row_key]['cells'][$col_key]['label'] = $variables['header'][$col_key]['content']; } } } diff --git a/core/modules/system/templates/table.html.twig b/core/modules/system/templates/table.html.twig index 3d0252e..b6eb9ad 100644 --- a/core/modules/system/templates/table.html.twig +++ b/core/modules/system/templates/table.html.twig @@ -85,7 +85,7 @@ %} {% for cell in row.cells %} - <{{ cell.tag }}{{ cell.attributes }}> + <{{ cell.tag }}{{ cell.attributes }} data-th="{{ cell.labelĀ }}"> {{- cell.content -}} {% endfor %} @@ -104,7 +104,7 @@ {% for row in footer %} {% for cell in row.cells %} - <{{ cell.tag }}{{ cell.attributes }}> + <{{ cell.tag }}{{ cell.attributes }} data-th="{{ cell.label }}"> {{- cell.content -}} {% endfor %} diff --git a/core/modules/views/templates/views-view-table.html.twig b/core/modules/views/templates/views-view-table.html.twig index 6b0b26c..c4db02c 100644 --- a/core/modules/views/templates/views-view-table.html.twig +++ b/core/modules/views/templates/views-view-table.html.twig @@ -61,7 +61,7 @@ {% for row in rows %} {% for column in row.columns %} - + {{ column.content }} {% endfor %} diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index ebef6f8..1e6ef5d 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -544,6 +544,10 @@ function template_preprocess_views_view_table(&$variables) { $column_reference['attributes']['class'][] = 'views-field-' . $variables['fields'][$field]; } + if (!empty($variables['header'][$field]['content'])) { + $column_reference['label'] = $label; + } + if ($classes = $fields[$field]->elementClasses($num)) { $column_reference['attributes']['class'][] = $classes; }