Shopify模板开发教程-页面动态输出模块

之前看模板时一直不清楚如何实现页面模块的一些配置,今天通过帮客户修改模板,总算搞清如何实现这个功能

shopify-dynamic-session

页面模板Session配置

shopify-dynamic-session-farjary

页面模板效果

效果实现分2步:

 

第一步:创建页面模板,在模板文件里要引用session文件

第二步:在session文件,插入类似如下代码,基于这段代码结合需求做修改

 

 

{{ section.settings.text-box }}

{% for block in section.blocks %}

{% endfor %}


{% schema %}
{
“name”: “CTA Blocks”,
“max_blocks”: 3,
“settings”: [
{
"id": "text-box",
"type": "text",
"label": "Heading",
"default": "Title"
}
],
“blocks”: [
{
"type": "select",
"name": "Add Button",
"settings": [
{
"id": "link",
"type": "url",
"label": "Button link"
},
{
"id": "linktext",
"type": "text",
"label": "Button text",
"default": "Click here"
}
]
}
],
“presets”: [
{
"name": "Call to Action Blocks",
"category": "CTA button",
"blocks": [
{
"type": "select"
},
{
"type": "select"
}
]
}
]
}
{% endschema %}

{% stylesheet %}
{% endstylesheet %}

{% javascript %}
{% endjavascript %}