Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
So I made some metaobjects with some inputs. See images. The issue I have is that the outputs are not in order for each date. How can I make the for loop to put out each row after the dates in order? From oldest to newest date?
<div class="tour-list-cont"> <h2>Rökarn on tour - Sverige Turné!</h2> <p style="color: #00aaff;"> OBS! Truck 1 står mellan 1:e Sep - 1:e Okt i Örebro vid Marieberg Gallerian!<br> Öppettider: Mån-Fre 11:00-20:00 | Lör-Sön 11:00-18:00. </p> <p><strong>Truck 2 är på turné, se listan nedan! 🔥🔥🔥</strong></p> <table width="100%"> <tbody> <tr> <td><span style="color: #ff8000;"><strong>DATUM</strong></span></td> <td><span style="color: #ff8000;"><strong>STAD</strong></span></td> <td><span style="color: #ff8000;"><strong>PLATS</strong></span></td> <td><span style="color: #ff8000;"><strong>TID</strong></span></td> </tr> {% for turne_lista in shop.metaobjects.turne_lista.values %} <tr> <td class="tour-date">{{ turne_lista.datum }}</td> <td>{{ turne_lista.stad }}</td> <td>{{ turne_lista.plats }}</td> <td>{{ turne_lista.tid }}</td> </tr> {% endfor %} </tbody> </table> </div>
Hey 46855004463, probably something like:
Remove reverse if still in the wrong order.
{% assign sorted_turne_lista = shop.metaobjects.turne_lista.values | sort: 'datum' | reverse %}
{% for turne_lista in sorted_turne_lista %}
{# your code to display each turne_lista item goes here #}
{% endfor %}
The list is not giving any output with that. I found same online and tried it before 😕
<div class="tour-list-cont">
<h2>Rökarn on tour - Sverige Turné!</h2>
<p style="color: #00aaff;">
OBS! Truck 1 står mellan 1:e Sep - 1:e Okt i Örebro vid Marieberg Gallerian!<br>
Öppettider: Mån-Fre 11:00-20:00 | Lör-Sön 11:00-18:00.
</p>
<p><strong>Truck 2 är på turné, se listan nedan! 🔥🔥🔥</strong></p>
<table width="100%">
<tbody>
<tr>
<td><span style="color: #ff8000;"><strong>DATUM</strong></span></td>
<td><span style="color: #ff8000;"><strong>STAD</strong></span></td>
<td><span style="color: #ff8000;"><strong>PLATS</strong></span></td>
<td><span style="color: #ff8000;"><strong>TID</strong></span></td>
</tr>
{% assign sorted_turne_lista = shop.metaobjects.turne_lista.values | sort: 'datum' | reverse %}
{% for turne_lista in sorted_turne_lista %}
<tr>
<td class="tour-date">{{ turne_lista.datum }}</td>
<td>{{ turne_lista.stad }}</td>
<td>{{ turne_lista.plats }}</td>
<td>{{ turne_lista.tid }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>