CERN Accelerating science

How to rewrite the result of a multiple value field in a view?

Hi everyone,

I’m trying to figure out how to get access to the values of a field that can contain multiple values in order to rewrite them in a view.

I have a content type which has two fields that can contain multiple values :

  • Position
  • Start/End date

I created a view with the following settings :

  • Format : Unformatted list
  • Show : Fields

Inside this view, i set a bunch of field that are hidden and rewrite the result using the replacement patterns in the last field. There i mix HTML + Twig in order to get the correct rendering.

The thing i don’t get is how to access each individual values of the field Position and Start/End date. I tried to use some loop to get through the value index of these fields but didn’t manage.

Here is a snippet of what i’m trying to accomplish :

<div class="wrapper-img-cards">
  <a href={{ view_node }}>
  {{ field_image_management}}
  </a>
</div>
<div class="wrapper-data-cards">
  <a href={{ view_node }}>
    <h3>{{ title }}</h3>
  </a>
  <div class="wrapper-subtitle-cards">
<!-- Here is where i want to loop through the values -->
    <p>{{ field_position }} | {{ field_starting_date_ending_date }}</p>
  </div>
</div>

Many thanks :slight_smile:

Maxime

Hey Maxime,

I think that what you are trying to do can be achieved from the view settings. Can you send a link to your view?

Thanks,

Konstantinos

Hi,

The view is named Previous management and i inserted it as a block on this page under ATLAS PREVIOUS MANAGEMENT.

Thank you very much :slight_smile:

Maxime

Hey Maxime,

Can you also tell why you want to rewrite the results, or in general what you try to achieve by rewriting?

Konstantinos

Hey,

So my goal would be to have combine position of the person and starting/ending date for their position on top of each other when they had several position.

I have one field position and one field starting/ending date. They can both have several values.

See below :

example

My issue now is that i don’t manage to get the multiple value that are in one field.

Is there a possibility to do so ?

Maxime