Reputation: 81
I need to get the list of images from my metafield(content type: collection list) in collection. I'm using this logic but it is not working...
Code snippet
{% assign top_collections = collection.metafields.custom.c-top-collections %}
{% if top_collections %}
<ul>
{% for collection in top_collections %}
<li>{{ collection.value }}</li>
{% endfor %}
</ul>
{% endif %}
Please, what is the correct form of doing this? Thank you.
Upvotes: 0
Views: 388
Reputation: 81
Example solution here with some variables being pulled:
{% assign collection-list = collection.metafields.menu.c-top-collections %}
{% for collection-list-item in collection-list.value -%}
{% if collection-list != blank %}
<img class="rounded-full h-28 w-28 object-cover object-center aspect-square " src="{{ collection-list-item | image_url }}" alt="{{ collection-list-item.image.alt }}"/>
<h2 class="text-xl mt-4 text-center">{{ collection-list-item.title }}</h2>
{% endif %}
{% endfor %}
Upvotes: 0
Reputation: 2173
To get your array you need to write this {{ collection.metafields.custom.c-top-collections.value }}
Upvotes: 1