1

How can I loop from col2 to col4 ? Or loop by column heading handle? Remplace {{ row.col2 }}

<ul class="features small-font-size">
  {% for row in block.tableHandle %}

      <li data-feature="{{ row.description }}">{{ row.col2 }}</li>

  {% endfor %}
</ul>

2 Answers 2

1

Is this what you're after?

{% for row in block.tableHandle %}

    {% for columnHandle, columnValue in row %}
        {# If not col1 #}
        {% if loop.index != 1 %}
            <p>Do whatever you want with: {{ columnValue }}</p>
        {% endif %}
    {% endfor %}

{% endfor %}
0

I'm not 100% sure I'm following the question, but if you just want to output every col2 and col4 row value, it'd be as simple as:

<ul>
    {% for row in block.tableHandle %}
        <li data-feature="{{ row.description }}">{{ row.col2 }} - {{ row.col4 }}</li>
    {% endfor %}
</ul>

There isn't a native way to loop directly by a column's handle.

1
  • I want to loop by column. Output all rows in column col2, all rows for col3 and all rows in col4 but in a loop. I don't want to repeat the codes 3 times.
    – NovoWeb
    Aug 4, 2017 at 16:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.