【问题标题】:Shopify theme editor crashing after creating sections for the homepageShopify 主题编辑器在为主页创建部分后崩溃
【发布时间】:2021-01-29 13:20:28
【问题描述】:

我正在尝试使用 Liquid 和 Schema 为 shopify 创建一个图库部分。在对代码进行一些处理后,主题编辑器呈现无响应或崩溃。我已尝试删除正在编辑的主题并发布备份,但备份主题的编辑器也会崩溃(即使该版本上甚至不存在新部分)。

一两天后,它似乎工作正常,但如果我创建另一个部分进行测试,它会再次无响应。真的不知道我在这里错过了什么。起初,Shopify 支持告诉我这是在他们这边,但事实并非如此,因为它发生在我创建新部分时。他们的解决方案是更新我没有发生的主题,因为我已经完成了广泛的自定义,并且 Shopify 的主题版本控制很糟糕。无论如何,这是我要创建的部分:

<div class="grid grid--no-gutters image-bar image-bar--{{ section.settings.section_height }}">
    {% for block in section.blocks %}

        <div class="image-wrap" style="background-image: url('{{ block.settings.image | img_url: '500x500' }}');">
        <h3>{{ block.settings.mention-text }}</h3>
        </div>
        
    {% endfor %}
</div>


{% schema %}
{
    "name": "Galeria",
    "settings": [
        {
            "type": "select",
            "id": "per-row",
            "label": "Images per row",
            "options": [
                {
                    "value": "49.5%",
                    "label": "2 per row"
                },
                {
                    "value": "33%",
                    "label": "3 per row"
                },
                {
                    "value": "24.5%",
                    "label": "4 per row"
                }
            ],
            "default": "24.5%"
        },
        {
           "type": "select",
           "id": "height",
           "label": "Image Height",
           "options": [
               {
                "value": "100px",
                "label": "100px"
               },
               {
                "value": "200px",
                "label": "200px"
            },
            {
                "value": "300px",
                "label": "300px"
            },
            {
                "value": "410px",
                "label": "450px"
            },
            {
                "value": "500px",
                "label": "500px"
            }
           ],
           "default": "500px"
        }
    ],
    "blocks": [
    {
        "type": "image",
        "name": "Image Block",
        "settings": [
                {
                    "type": "image_picker",
                    "id": "image",
                    "label": "Image"
                },
                {
                    "type": "text",
                    "id": "mention_text",
                    "label": "Mention user",
                    "placeholder": "@"
                }
            ]
        }
    ],
    "presets": [
        {
            "category": "Galeria",
            "name": "Galeria"
        }
    ]
}
{% endschema %}
{% style %}

.image-wrap {
    display: inline-block;
    width: {{section.settings.per-row}};
    height: {{section.settings.height}};
    background-size: 100%;
}

.page-width.galeria-testimonial {
    width: 90%;
    margin: 0 auto;
}

{% endstyle %}

【问题讨论】:

    标签: themes shopify liquid database-schema shopify-template


    【解决方案1】:

    我认为您需要从 settings_data.json 文件中删除部分信息。您创建的所有部分都存储在此处的 JSON 对象,有时在文件删除时不会删除,您需要手动删除它。我建议您打开该文件并查找 Galeria 并删除该部分的 json 对象。

    This article can help in your understanding of themes.

    另一个建议是在 Shopify 之外开始对您的主题进行版本控制,您可以进行版本控制并使用暂存主题来测试新功能/更改,以便更好地控制和测试版本,而不会弄乱您的现场网站。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-02-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-15
      • 1970-01-01
      相关资源
      最近更新 更多