{# /** * @file * Default view template to display all the fields in a row. * * Available variables: * - view: The view in use. * - fields: A list of fields, each one contains: * - content: The output of the field. * - raw: The raw data for the field, if it exists. This is NOT output safe. * - class: The safe class ID to use. * - handler: The Views field handler controlling this field. * - inline: Whether or not the field should be inline. * - wrapper_element: An HTML element for a wrapper. * - wrapper_attributes: List of attributes for wrapper element. * - separator: An optional separator that may appear before a field. * - 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. * - element_attributes: List of attributes for HTML element for field content. * - row: The raw result from the query, with all data it fetched. * * @see template_preprocess_views_view_fields() * * @ingroup themeable */ #} {% for field in fields -%} {# Add ZURB Foundation Accordion specific markup wrappers: #} {%- if loop.index0 == 0 -%} {# Around the first field #} {## Accordion title: ##} {%- elseif loop.index0 == 1 -%} {# Closing after the first field and around all following fields #} {## Accordion title END (a): ##} {## Accordion content wrapper: ##}
{%- endif -%} {## Field separator: ##} {{ field.separator }} {## Field wrapper: ##} {%- if field.wrapper_element -%} <{{ field.wrapper_element }}{{ field.wrapper_attributes }}> {%- endif %} {## Field label: ##} {%- if field.label -%} {%- if field.label_element -%} <{{ field.label_element }}{{ field.label_attributes }}>{{ field.label }}{{ field.label_suffix }} {%- else -%} {{ field.label }}{{ field.label_suffix }} {%- endif %} {%- endif %} {## Field content: ##} {# Ensure there's no markup inside the first field, which acts as accordion-title #} {% set field_content %} {%- if loop.index0 == 0 -%} {# Prevent twig double escaping of special characters in accordion: #} {# Rendering the Markup object first, ensures it's safely escaped. #} {# See https://www.drupal.org/project/views_accordion_foundation/issues/3367921 #} {{ field.content|render|striptags|raw }} {%- else -%} {{ field.content }} {%- endif %} {% endset %} {%- if field.element_type -%} <{{ field.element_type }}{{ field.element_attributes }}>{{ field_content }} {%- else -%} {{ field_content }} {%- endif %} {## Field wrapper END: ##} {%- if field.wrapper_element -%} {%- endif %} {## Accordion loop closing elements: ##} {%- if loop.length == 1 and loop.last -%} {# Closing first field if there are no further fields #} {## Accordion title END (b): ##} {%- endif -%} {%- if loop.last and loop.length > 1 -%} {# Closing closing after all other fields #} {## Accordion content wrapper END: ##}
{%- endif -%} {%- endfor %}