HubL / Twig: Not finding value from array

504 Views Asked by At

In HubSpot, I've created a custom module called footer. footer has five field types of menu:

enter image description here

I've created an array where all five of the above menu ID's are pushed to an array. I've done this via a template partial file which is included in my footer module.

<!-- creating array -->
{% set footer_id_array = [] %}

<!-- push menu id's to array -->
{% do footer_id_array.append(module.menus.menu_column_1) %}
{% do footer_id_array.append(module.menus.menu_column_2) %}
{% do footer_id_array.append(module.menus.menu_column_3) %}
{% do footer_id_array.append(module.menus.menu_column_4) %}
{% do footer_id_array.append(module.menus.menu_column_5) %}

Running {{ footer_id_array }} shows all the IDs in the array, i.e.

[29420054435, 29420223163, 29420054590, 29420158158, 29420071857]

So this is correct, the array contains the IDs.

Now, for each item in this array, I want to generate a nav, so in my footer custom module, I have the following:

{% set iterations = range(0, 5) %}

{% for i in iterations %}
     <nav>
          {% menu id="{{ footer_id_array[i] }}" %}
     </nav>
{% endfor %}

However, on my page, this just prints HubSpots default menus, not the ones assigned to the ID's.

Why is this?

0

There are 0 best solutions below