Skip to main content
added 4 characters in body
Source Link
No Sssweat
  • 31.6k
  • 14
  • 55
  • 91

I am working on a field template to display images in a carousel (I'm using BootStrap). My field is named “galerie”
I copied field.html.twig from the core and saved it as field--field-galerie.html.twig
I managed successfuly to add the necessary markup for BootStrap carousel to work.

The wrapping markup displaying the carousel and its control shows up when there is only one image. I thought it would not. It opens after a {% if multiple %}{% if multiple %} condition and closes before the {% else %}{% else %}.
My understanding is that {% if multiple %}{% if multiple %} only checks if the field is set to accept multiple values.

I don't know how to write an condition in twig checking if the field contains one image or more, to trigger (or not) the carousel thingee.

I am working on a field template to display images in a carousel (I'm using BootStrap). My field is named “galerie”
I copied field.html.twig from the core and saved it as field--field-galerie.html.twig
I managed successfuly to add the necessary markup for BootStrap carousel to work.

The wrapping markup displaying the carousel and its control shows up when there is only one image. I thought it would not. It opens after a {% if multiple %} condition and closes before the {% else %}.
My understanding is that {% if multiple %} only checks if the field is set to accept multiple values.

I don't know how to write an condition in twig checking if the field contains one image or more, to trigger (or not) the carousel thingee.

I am working on a field template to display images in a carousel (I'm using BootStrap). My field is named “galerie”
I copied field.html.twig from the core and saved it as field--field-galerie.html.twig
I managed successfuly to add the necessary markup for BootStrap carousel to work.

The wrapping markup displaying the carousel and its control shows up when there is only one image. I thought it would not. It opens after a {% if multiple %} condition and closes before the {% else %}.
My understanding is that {% if multiple %} only checks if the field is set to accept multiple values.

I don't know how to write an condition in twig checking if the field contains one image or more, to trigger (or not) the carousel thingee.

Source Link
Mars
  • 105
  • 3
  • 15

How to check if a field has more than one value

I am working on a field template to display images in a carousel (I'm using BootStrap). My field is named “galerie”
I copied field.html.twig from the core and saved it as field--field-galerie.html.twig
I managed successfuly to add the necessary markup for BootStrap carousel to work.

The wrapping markup displaying the carousel and its control shows up when there is only one image. I thought it would not. It opens after a {% if multiple %} condition and closes before the {% else %}.
My understanding is that {% if multiple %} only checks if the field is set to accept multiple values.

I don't know how to write an condition in twig checking if the field contains one image or more, to trigger (or not) the carousel thingee.