diff --git a/core/modules/views/templates/views-view-table.tpl.php b/core/modules/views/templates/views-view-table.tpl.php index 4d44d42..705f22a 100644 --- a/core/modules/views/templates/views-view-table.tpl.php +++ b/core/modules/views/templates/views-view-table.tpl.php @@ -15,6 +15,8 @@ * $rows are keyed by row number, fields within rows are keyed by field ID. * - $field_classes: An array of classes to apply to each field, indexed by * field id, then row number. This matches the index in $rows. + * - $id : An array of unique IDs for each column which improve accessibility. + * - $headers : An array of column headers linked with it's associated $id. * @ingroup views_templates */ @@ -27,7 +29,7 @@ $label): ?> - scope="col"> + id=""> @@ -38,7 +40,7 @@ $row): ?> > $content): ?> - > + headers=""> diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index 44f48f6..e8b2ba4 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -480,6 +480,7 @@ function template_preprocess_views_view_table(&$vars) { $query += $view->exposed_raw_input; } +$vars['id'] = array(); foreach ($columns as $field => $column) { // Create a second variable so we can easily find what fields we have and what the // CSS classes should be. @@ -543,6 +544,8 @@ function template_preprocess_views_view_table(&$vars) { if ($element_label_type) { $vars['header'][$field] = '<' . $element_label_type . '>' . $vars['header'][$field] . ''; } + // Improves accessibility of complex tables. + $vars['id'][$field] = drupal_html_id('view-' . $field . '-table-column'); } } @@ -570,6 +573,9 @@ function template_preprocess_views_view_table(&$vars) { $vars['field_classes'][$field][$num]['class'][] = $options['info'][$field]['responsive']; } + // Improves accessibility of complex tables. + $vars['headers'][$field] = drupal_html_id('view-' . $field . '-table-column'); + if (!empty($fields[$field]) && empty($fields[$field]->options['exclude'])) { $field_output = $handler->get_field($num, $field); $element_type = $fields[$field]->element_type(TRUE, TRUE);