Skip to content

Instantly share code, notes, and snippets.

@iamkeir
Created November 20, 2019 23:33
Show Gist options
  • Save iamkeir/72c43f626d0a8210a22111a260f2c573 to your computer and use it in GitHub Desktop.
Save iamkeir/72c43f626d0a8210a22111a260f2c573 to your computer and use it in GitHub Desktop.
Shopify: Dynamic section hack
{% comment %}Workaround for dynamic sections outside of homepage{% endcomment %}
{% for block in section.blocks %}
{% if product.handle == block.settings.product %}
{%
include 'hero'
hero_title: block.settings.title
%}
{% endif %}
{% endfor %}
{% schema %}
{
"name": "Product hero",
"settings": [
{ "type": "paragraph", "content": "Edit the item that matches the current product." },
{ "type": "paragraph", "content": "If no matching item exists, add a new section and choose the current product from the dropdown." }
],
"blocks": [
{
"type": "product_hero",
"name": "Product hero",
"settings": [
{
"id": "product",
"type": "product",
"label": "Product"
},
{
"type": "text",
"id": "title",
"label": "Hero title"
}
]
}
]
}
{% endschema %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment