Hi Everyone,
I’m trying to loop through a collection list but it doesn’t show the image because it thinks the source is empty.
Does anybody see the bug in the code?
{% style %}
/* Style for the image grid */
.collection-grid-{{ section.id }} {
}
/* Container styles */
.collection-grid-{{ section.id }} .page-width {
padding: 0;
padding-top: {{section.settings.padding_top}}px;
padding-bottom: {{section.settings.padding_bottom}}px;
margin-top: {{section.settings.margin_top}}px;
margin-bottom: {{section.settings.margin_bottom}}px;
border-top: {{section.settings.border_width_top}}px solid {{section.settings.border_color_top}};
border-bottom: {{section.settings.border_width_bottom}}px solid {{section.settings.border_color_bottom}};
}
@media screen and (max-width: 1180px) and (orientation: portrait), screen and (max-width: 1024px) {}
@media screen and (max-width: 1180px) and (orientation: portrait) {}
@media screen and (max-width: 1180px) and (orientation: landscape) {}
@media screen and (max-width: 767px) {}
{% endstyle %}
<div class="container collection-grid-{{ section.id }}" data-section-id="{{ section.id }}">
<div class="page-width">
{% for block in section.blocks %}
{%- case block.type -%}
{%- when 'heading' -%}
{% style %}
/* Style for the image grid */
.collection-grid-{{ section.id }} .title-{{ block.id }} {
font-size: {{ block.settings.font-size-desktop }}px;
line-height: {{ block.settings.line-height-desktop }}px;
color: {{ block.settings.text-color }};
text-align: {{ block.settings.text-align }};
margin-block-start: 0;
margin-block-end: 0;
}
@media screen and (max-width: 1180px) and (orientation: portrait), screen and (max-width: 1024px) {
.collection-grid-{{ section.id }} .title-{{ block.id }} {
font-size: {{ block.settings.font-size-tablet }}px;
line-height: {{ block.settings.line-height-tablet }}px;
}
}
@media screen and (max-width: 767px) {
.collection-grid-{{ section.id }} .title-{{ block.id }} {
font-size: {{ block.settings.font-size-mobile }}px;
line-height: {{ block.settings.line-height-mobile }}px;
}
}
{% endstyle %}
<h2 class="title-{{ block.id }}">{{ block.settings.text }}</h2>
{%- when 'collection-list' -%}
{% for collection in collections %}
<div class="collection">
<a href="{{ collection.url }}">
<img src="{{ collectiion.image.src }}" alt="{{ collection.title }}">
<h3>{{ collection.title }}</h3>
<p>{{ collection.description }}</p>
</a>
</div>
{% endfor %}
{%- endcase -%}
{% endfor %}
</div>
</div>
{% schema %}
{
"name":"Collection list",
"tag":"section",
"class":"section",
"settings":[
{
"type":"range",
"id":"padding_top",
"min":0,
"max":99,
"step":3,
"unit":"px",
"label":"Padding top",
"default":60
},
{
"type":"range",
"id":"padding_bottom",
"min":0,
"max":99,
"step":3,
"unit":"px",
"label":"Padding bottom",
"default":60
},
{
"type":"range",
"id":"margin_top",
"min":0,
"max":99,
"step":3,
"unit":"px",
"label":"Margin top",
"default":0
},
{
"type":"range",
"id":"margin_bottom",
"min":0,
"max":99,
"step":3,
"unit":"px",
"label":"Margin bottom",
"default":0
}
],
"blocks":[
{
"type":"heading",
"name":"Heading",
"settings":[
{
"type":"text",
"id":"text",
"label":"heading"
},
{
"type":"select",
"id":"text-align",
"options":[
{
"value":"left",
"label":"Left"
},
{
"value":"center",
"label":"Center"
},
{
"value":"right",
"label":"Right"
}
],
"default":"left",
"label":"Text align"
},
{
"type":"range",
"id":"font-size-desktop",
"min":0,
"max":200,
"step":2,
"unit":"px",
"label":"Font size (desktop)",
"default":36
},
{
"type":"range",
"id":"line-height-desktop",
"min":0,
"max":200,
"step":2,
"unit":"px",
"label":"Line height (desktop)",
"default":48
},
{
"type":"color",
"id":"text-color",
"label":"Text color",
"default":"#d4b2a6"
},
{
"type":"range",
"id":"font-size-tablet",
"min":0,
"max":200,
"step":2,
"unit":"px",
"label":"Font size (tablet)",
"default":36
},
{
"type":"range",
"id":"line-height-tablet",
"min":0,
"max":200,
"step":2,
"unit":"px",
"label":"line-height (tablet)",
"default":48
},
{
"type":"range",
"id":"font-size-mobile",
"min":0,
"max":200,
"step":2,
"unit":"px",
"label":"Font size (mobile)",
"default":36
},
{
"type":"range",
"id":"line-height-mobile",
"min":0,
"max":200,
"step":2,
"unit":"px",
"label":"line-height (mobile)",
"default":48
}
]
},
{
"type":"collection-list",
"name":"Collection list",
"settings":[
{
"type": "collection_list",
"id": "collection_list",
"label": "Collections",
"limit": 8
}
]
}
],
"presets":[
{
"name":"Collection grid",
"category":"column"
}
]
}
{% endschema %}
It the small html code after {%- when ‘collection-list’ -%}.
Kind regards
Mathijs



