-
Notifications
You must be signed in to change notification settings - Fork 32
Sorting when iterating #56
Comments
Hi @jaybrueder, There's the {% for post in site.data.contentful.spaces.blog.posts | sort: 'title' %}
<h1>{{post.title}}</h1>
{% endfor %} That said, looks like your data may need some re-structuring, or you need to do some extra looping, as it looks that you're fetching the titles from objects nested in your You can learn more about Liquid filters here: https://help.shopify.com/themes/liquid/filters/array-filters As for the ID issue, you can access it as if it were a hash key Cheers |
Thank you for your help! Organising the data into one YAML file makes this problem go away.
|
That's great! Glad it worked out. Cheers |
Hi,
I have a list of data objects and iterate over them like so:
This works great. However, the order in which the objects are listed depends on the ID value that each content object gets from Contentful.
These look like this for example:
ID: 1m3ap... Title: Open...
ID: 5kFqz... Title: Agile...
ID: UL3CJ... Title: Infrastructure...
Therefore, the list looks as follows:
What I would like is and alphabetical order:
Is there a way that I can bring order into the iteration?
Maybe I can use the title field as the ID of the object?
That would also solve this problem for me:
#57
The text was updated successfully, but these errors were encountered: