shopify开发常用代码集合

本文详细介绍了如何在网站中启用特定主题选项(themewatch--allow-live)和下拉菜单(themeget),展示了for循环、条件判断、图片引用及schema设置的实例。同时涵盖了CSS媒体查询和自定义样式,以及项目结构的Schema配置。
摘要由CSDN通过智能技术生成
  1. 启用和下拉代码
启用 : theme watch --allow-live
下拉 : theme get
  1. 常用代码
// for循环
{% for block in section.blocks %}
   {{block.settings.product_name}}
{% endfor %}

// 判断
{% if form.context == 'footer' %}
{% endif %}
   
// img         
<img src="{{ block.settings.product_img | img_url: 'master' }}" alt="" class="lazyload mobile-hide">

// 获取setting
{{ section.settings.header }}

  1. css
@media screen and (min-width: 769px) {
.more_deals_wrap {
        padding-bottom: 4.5vw;
        background: #F5F5F7;
  }
.more_deals_wrap  .more_deals_header {
        padding: 4.5vw 0;
        text-align: center;
  }
.more_deals_wrap .more_deals_item {
        max-width: 1400px;
        display: flex;
        justify-content: space-between;
  }
.more_deals_wrap  .content_one {
        width: calc(25% - 1vw);
        box-sizing: border-box;
        max-height: 310px;
        padding-bottom: 2vw;
        border: 1px solid #DEDEDE;
        background-color: #fff;
      }
}
@media screen and (max-width: 768px) {}
  1. schema设置
{% schema %}
  {
    "name": "more deals",
    "settings": [
      {
        "type": "text",
        "id": "header",
        "label": "more deals header"
      }
    ],
    "blocks": [
        {
            "type": "more",
            "name": "they_saying items",
            "limit": 4,
            "settings": [
                {
                    "type": "image_picker",
                    "id": "product_img",
                    "label": "item image"
                },
                {
                    "type": "text",
                    "id": "product_name",
                    "label": "item name"
                },
                {
                  "type": "url",
                  "id": "product_url",
                  "label": "item link"
                }
            ]
        }
    ],
    "presets": [{
      "name": "more deals"
    }]
  }
  
  {% endschema %}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值