orange_starter-2.0.x-dev/templates/field/field--paragraph--field-paragraphs--carousel.html.twig
templates/field/field--paragraph--field-paragraphs--carousel.html.twig
{#
/**
* @file
* Theme override for a Paragraphs Reference field within a Carousel.
*
* Available variables:
* - attributes: HTML attributes for the containing element.
* - label_hidden: Whether to show the field label or not.
* - title_attributes: HTML attributes for the title.
* - label: The label for the field.
* - multiple: TRUE if a field can contain multiple items.
* - items: List of all the field items. Each item contains:
* - attributes: List of HTML attributes for each item.
* - content: The field item's content.
* - entity_type: The entity type to which the field belongs.
* - field_name: The name of the field.
* - field_type: The type of the field.
* - label_display: The display settings for the label.
*
* @see template_preprocess_field()
*/
#}
{%
set classes = [
'field',
'field--name-' ~ field_name|clean_class,
'field--type-' ~ field_type|clean_class,
'field--label-' ~ label_display,
]
%}
{# Add class to hide carousel navigation if there's only 1 slide. #}
{% set item_total = items|length %}
{% if item_total < 2 %}
{% set attributes = attributes.addClass('component-carousel__slider--no-nav') %}
{% endif %}
<div{{ attributes.addClass(classes, 'component-carousel__slider') }}>
{% for item in items %}
<div{{ item.attributes.addClass('component-carousel__slider__item') }}>{{ item.content }}</div>
{% endfor %}
</div>
