CMS Development

kaitlyn
Participante

HUBL: For loop item within a variable call issue {{ row.item }}

resolver

Is there a way to include a for loop item within another variable call? For example, below I have a for loop, looping over the rows in a HubDB table. Inside, I have another for loop, looping over items in an array.

 

Inside that, there's a paragraph, where I'd like to echo out the row's value for the column labeled "column_1" (example for during the first iteration of the loop).

 

Right now, {{ row.item }} is looking for a column called "item" instead of pulling "item" from the for loop. How can I fix this?

 

{% set exampleArray = ['column_1', 'column_2'] %}

{% for row in hubdb_table_rows(dynamic_page_hubdb_table_id) %}
    {% for item in exampleArray %}
        <p>{{ item }}: {{ row.item }}</p>
    {% endfor %}
{% endfor %}

 

0 Avaliação positiva
1 Solução aceita
tjoyce
Solução
Especialista reconhecido(a) | Parceiro Elite
Especialista reconhecido(a) | Parceiro Elite

HUBL: For loop item within a variable call issue {{ row.item }}

resolver

@kaitlyn - I haven't tested this but can you try row[item]

Exibir solução no post original

0 Avaliação positiva
3 Respostas 3
tjoyce
Solução
Especialista reconhecido(a) | Parceiro Elite
Especialista reconhecido(a) | Parceiro Elite

HUBL: For loop item within a variable call issue {{ row.item }}

resolver

@kaitlyn - I haven't tested this but can you try row[item]

0 Avaliação positiva
kaitlyn
Participante

HUBL: For loop item within a variable call issue {{ row.item }}

resolver

That worked, thank you!

tjoyce
Especialista reconhecido(a) | Parceiro Elite
Especialista reconhecido(a) | Parceiro Elite

HUBL: For loop item within a variable call issue {{ row.item }}

resolver

lucky guess 😄

0 Avaliação positiva