I’m currently trying to migrate from a Vintage Shopify theme to Shopify 2.0’s Dawn theme.
I’m trying to recreate something I was able to accomplish with the Vintage theme, but I’m hitching up on one bit. This is what it currently looks like: https://shop.march1studios.com/pages/ttrpg
Each of those blocks is either a page of collections, or a collection. The pages take the first collection in their own linklist and use that as the image on this page, and look like the straight collections except they have a count on how many designs are on those pages.
I’m almost able to do this with the code below, but I don’t know how to grab the image from the first collection, and pass it to the ‘card_collection’ render.
{{ 'component-card.css' | asset_url | stylesheet_tag }}
{{ 'section-collection-list.css' | asset_url | stylesheet_tag }}
{% assign collections = linklists[page.handle].links %}
{% assign collections = collections | reverse %}
{% for link in collections %}
{% if link.type == 'collection_link' %}
{% assign collection = link.object %}
- {% render 'card-collection',
card_collection: collection,
media_aspect_ratio: section.settings.image_ratio,
columns: 3
%}
{% elsif link.type == 'page_link' %}
// use title and url from page
// get first collection image from that pages linklist
// pass to'card-collection' as collection object
- {% render 'card-collection',
card_collection: collection,
media_aspect_ratio: section.settings.image_ratio,
columns: 3
%}
{% endif -%}
"
{% endfor %}
{% schema %}
{
"name": "Category Collections",
"class": "section",
"settings": [
{
"type": "select",
"id": "image_ratio",
"options": [
{
"value": "adapt",
"label": "t:sections.main-list-collections.settings.image_ratio.options__1.label"
},
{
"value": "portrait",
"label": "t:sections.main-list-collections.settings.image_ratio.options__2.label"
},
{
"value": "square",
"label": "t:sections.main-list-collections.settings.image_ratio.options__3.label"
}
],
"default": "adapt",
"label": "t:sections.main-list-collections.settings.image_ratio.label",
"info": "t:sections.main-list-collections.settings.image_ratio.info"
},
{
"type": "range",
"id": "columns_desktop",
"min": 1,
"max": 5,
"step": 1,
"default": 3,
"label": "t:sections.main-list-collections.settings.columns_desktop.label"
},
{
"type": "select",
"id": "columns_mobile",
"options": [
{
"value": "1",
"label": "t:sections.main-list-collections.settings.columns_mobile.options__1.label"
},
{
"value": "2",
"label": "t:sections.main-list-collections.settings.columns_mobile.options__2.label"
}
],
"default": "2",
"label": "t:sections.main-list-collections.settings.columns_mobile.label"
}
],
"presets": [
{"name": "Category Collection List"}
]
}
{% endschema %}