I have been trying to iterate an output of a section using variables, but I cannot find a way to output the liquid object dynamically by concatenating the index. images[i]
is the id of the image that I set in the {% schema %}
section.
{% for i in (1 .. 5) %}
{% if section.settings.images[i] != blank %}
{{ section.settings.image[i] }}
{% endif %}
{% endfor %}
2
Answers
You were almost there.
You need to assign the handle/id, since at the moment
images[i]
points to an array of images which is not correct.The code should be something like this:
Assuming that your images ID are called
images1
,images2
,images3
etc..PS:
I’m not sure of your full code, but if you have a section and if you’re not using its blocks why don’t you use them instead of predefined sections fields?
I want this code exactly, Thank you very much…
This is my sample code.