I feel like there should be an easy way to do this, but I can't find it. I need specifically chose a child from a collection while looping through the collection. The order doesn't really matter, just as long as I can pick say the nth child in the collection wherever I need it and place it where I want to. I guess I don't even need to loop through the collection. I just need to select each child specifically. I'm aware of
loop.first and loop.last
---
but what about children in-between the first and last?
I have a page that needs to show each child in a portfolio of items, but each item is not formatted the same way. The general layout is
<div class="style1">
<img src="image1.jpg">
<a href="/path/to/first/item/"
</div>
<div class="style2">
<img src="image2.jpg">
<a href="/path/to/second/item/"
</div>
<div class="style3">
<img src="image3.jpg">
<a href="/path/to/third/item/"
</div>
And so on. I can't just iterate over the entire collection because I need the first child to be in "style1", the second child in "style2" and so on. I tried
{% for child in collection %}
{% if loop.first %}
<div class="style1">
<img src="{{ child.media.image|first.url }}">
<a href="{{ child.url }}"
</div>
{% endif %}
<div class="style2">
<img src="image2.jpg">
<a href="/path/to/second/item/"
</div>
<div class="style3">
<img src="image3.jpg">
<a href="/path/to/third/item/"
</div>
{% endfor %}
which works for the first child, but no others. I tried other things like
{% set first_child = collection[1:1] %} and {% set first_child = collection|slice(0,1) %}
to no avail. Any thoughts?