All things Shopify and commerce
Is there a way to add multiple blocks sections to a Shopify schema?
Wiivv its possible yes by putting inside "blocks" array multiple block objects..
for example
{% schema %}
{
"name": "Multiple Blocks",
"blocks":[
{
"type": "block-1",
"name": "Block 1",
"settings": [
{
"type": "text",
"id": "title",
"label": "Title"
}
]
},
{
"type": "block-2",
"name": "Block 2",
"settings": [
{
"type": "text",
"id": "title",
"label": "Title"
}
]
}
]
}
{% endschema %}
{% for block in section.blocks %}
{% if block.type == 'block-1' %}
<h2>{{block.title}}</h2>
{% elsif block.type == 'block-2' %}
<h3>{{block.title}}</h3>
{% endif %}
{% endfor %}
Hope that helps
It helps tons.
If someone else find it uselful but can't make it work, you might have to replace
{{block.title}}
with
{{block.settings.title}}
Cheers.
It helps a lot, Thanks for the solution.
User | RANK |
---|---|
32 | |
28 | |
27 | |
17 | |
15 |
Thanks to all who participated in our AMA with 2H Media on planning your 2023 marketing bu...
By Jacqui Mar 30, 2023Thanks to all Community members that participated in our inaugural 2 week AMA on the new E...
By Jacqui Mar 10, 2023Upskill and stand out with the new Shopify Foundations Certification program
By SarahF_Shopify Mar 6, 2023