diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 248c795..89cdc53 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1697,6 +1697,25 @@ function template_preprocess_table(&$variables) { } /** + * Prepares variables for tablesort indicator templates. + * + * Default template: tablesort-indicator.html.twig. + * + * @param array $variables + * An associative array containing: + * - style: Set to either 'asc' or 'desc'. This determines which icon to show. + */ +function template_preprocess_tablesort_indicator(&$variables) { + // Provide the image attributes for an ascending or descending image. + if ($variables['style'] == 'asc') { + $variables['arrow_asc'] = file_create_url('core/misc/arrow-asc.png'); + } + else { + $variables['arrow_desc'] = file_create_url('core/misc/arrow-desc.png'); + } +} + +/** * Prepares variables for item list templates. * * Default template: item-list.html.twig. diff --git a/core/modules/system/templates/tablesort-indicator.html.twig b/core/modules/system/templates/tablesort-indicator.html.twig index 1f0eb9d..5d612fe 100644 --- a/core/modules/system/templates/tablesort-indicator.html.twig +++ b/core/modules/system/templates/tablesort-indicator.html.twig @@ -5,12 +5,16 @@ * * Available variables: * - style: Either 'asc' or 'desc', indicating the sorting direction. + * - arrow_asc: URL to the image for an ascending arrow. + * - arrow_desc: URL to the image for a descending arrow. + * + * @see template_preprocess_tablesort_indicator() * * @ingroup themeable */ #} {% if style == 'asc' -%} - {{ 'sort ascending'|t }} + {{ 'sort ascending'|t }} {% else -%} - {{ 'sort descending'|t }} + {{ 'sort descending'|t }} {% endif %}