
Is it possible to merge a secondary level array into a primary array without creating new primary arrays. For example I have a set of “tiles” that need to have an array of “list” that I’m merging like so.
{% set tiles = [] %} {% set list = [] %}
{% for item in content.field_tiles %}
{% if item['#paragraph'].field_image.value %}
{% set tiles = tiles | merge([{
'image': file_url(item['#paragraph'].field_image.entity.uri.value),
'title': item['#paragraph'].field_link_tile.title,
'url': item['#paragraph'].field_link_tile[0].url,
}]) %}
{% endif %} {% endfor %}
I then need to loop through another for loop to populate the list, the below does not work but I think you get the idea of what I want to do.
{% for i in 0..numTagsIndex %}
{% set tiles.list = tiles.list | merge([{
'content': paragraph.field_tiles.entity.field_link_list.entity.field_links[i],
}]) %}
{% endfor %}