diff --git a/core/modules/views/templates/views-view-fields.html.twig b/core/modules/views/templates/views-view-fields.html.twig index c06c1a8..64bd791 100644 --- a/core/modules/views/templates/views-view-fields.html.twig +++ b/core/modules/views/templates/views-view-fields.html.twig @@ -17,6 +17,9 @@ * - label: The field's label text. * - label_element: An HTML element for a label wrapper. * - label_attributes: List of attributes for label wrapper. + * - label_suffix: Colon after the label. + * - element_type: An HTML element for the field content. + * - element_attributes: List of attributes for HTML element for field content. * - has_label_colon: A boolean indicating whether to display a colon after * the label. * - element_type: An HTML element for the field content. @@ -28,12 +31,6 @@ * @ingroup themeable */ #} -{# -THIS FILE IS NOT USED AND IS HERE AS A STARTING POINT FOR CUSTOMIZATION ONLY. -See http://api.drupal.org/api/function/theme_views_view_fields/8 for details. -After copying this file to your theme's folder and customizing it, remove this -comment. -#} {% for field in fields -%} {{ field.separator }} {%- if field.wrapper_element -%} @@ -41,9 +38,9 @@ comment. {%- endif %} {%- if field.label -%} {%- if field.label_element -%} - <{{ field.label_element }}{{ field.label_attributes }}>{{ field.label }}{{ field.has_label_colon ? ': ' }} + <{{ field.label_element }}{{ field.label_attributes }}>{{ field.label }}{{ field.label_suffix }} {%- else -%} - {{ field.label }}{{ field.has_label_colon ? ': ' }} + {{ field.label }}{{ field.label_suffix }} {%- endif %} {%- endif %} {%- if field.element_type -%} diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index f34d076..89c0f86 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -148,6 +148,7 @@ function template_preprocess_views_view_fields(&$variables) { if ($object->label) { // Add a colon in a label suffix. if ($object->handler->options['element_label_colon']) { + $object->label_suffix = ': '; $object->has_label_colon = TRUE; } @@ -162,6 +163,7 @@ function template_preprocess_views_view_fields(&$variables) { $attributes['class'][] = 'views-label-' . $object->class; } + // Set up field label. $element_label_class = $object->handler->elementLabelClasses($row->index); if ($element_label_class) { $attributes['class'][] = $element_label_class; @@ -177,61 +179,6 @@ function template_preprocess_views_view_fields(&$variables) { } /** - * Returns HTML for multiple views fields. - * - * @param $variables - * An associative array containing: - * - fields: An array of field objects. Each field object contains: - * - separator: A string that separates the fields. - * - wrapper_suffix: A string added to the beginning of the fields. - * - label_html: An HTML string that labels the fields. - * - content: The fields. - * - wrapper_suffix: A string added to the end of the fields. - * - * @see template_preprocess_views_view_fields() - * - * @ingroup themeable - */ -function theme_views_view_fields($variables) { - $fields = $variables['fields']; - $output = ''; - - foreach ($fields as $field) { - if (!empty($field->separator)) { - $output .= $field->separator; - } - $wrapper_element = Html::escape($field->wrapper_element); - if ($wrapper_element) { - $output .= '<' . $wrapper_element . $field->wrapper_attributes . '>'; - if (isset($field->label_element) && !empty($field->label_element)) { - $label_element = Html::escape($field->label_element); - $output .= '<' . $label_element . $field->label_attributes . '>'; - } - $output .= Html::escape($field->label); - if ($field->has_label_colon) { - $output .= ': '; - } - if (isset($label_element)) { - $output .= ''; - } - } - $element_type = Html::escape($field->element_type); - if ($element_type) { - $output .= '<' . $element_type . $field->element_attributes . '>'; - } - $output .= $field->content; - if ($element_type) { - $output .= ''; - } - if ($wrapper_element) { - $output .= ''; - } - } - - return $output; -} - -/** * Prepares variables for views single grouping templates. * * Default template: views-view-grouping.html.twig.