Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
247 views
in Technique[技术] by (71.8m points)

Creating linkable Image with Text in Blocks Shopify

I tried to make a block in Shopify section, a linkable image with text - they should be made a new section for my page and has 3 features: adding an image, link for the image, a header and description. Also it could has 2 column. But, this script cannot be saved. Here is it's

  {% for block in section.blocks %}  
  <div class="img" id="call-to-action">   
        <h1> {{ block.settings.text-box-title }} </h1>
        <h3> {{ block.settings.text-box-content }} </h3>
        <a href="{{ image-settings.link }}" class="img img--cta">{{ image.settings.link }}</a>
    </div>
  {% endfor %}


{% schema %}
{
  "name": "CTA Blocks",
  "max_blocks": 3,
   "settings": [
    {
      "id": "text-box",
      "type": "text",
      "label": "Heading",
      "default": "Title"
    }
  ],
  "blocks": [
    {
      "name": "Add Image with Text",
      "settings": [
        {
          "id": "image",
          "type": "image_picker",
            "label": "Image"
        },
        {
          "id": "link",
          "type": "url",
        "label": "Image link"
        },
        {
        "name": "Text Box",
        "settings": [
            {
                "id": "text-box-title",
                "type": "text",
                "label": "Heading",
                "default": "Title"
            },
            {
                "id": "text-box-content",
                "type": "richtext",
                "label": "Add custom text below",
                "default": "<p>Add your text here</p>"
        }
      ]
    }
  ],
  "presets": [
    {
      "name": "Call to Action Blocks",
      "category": "CTA button",
      "blocks": [
        { 
          "type": "select"
        },
        {
          "type": "select"
        }
      ]
    }
  ]
}
{% endschema %}

{% stylesheet %}
{% endstylesheet %}

{% javascript %}
{% endjavascript %}
question from:https://stackoverflow.com/questions/65951914/creating-linkable-image-with-text-in-blocks-shopify

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You have invalid JSON, it should be:

{
    "name": "CTA Blocks",
    "max_blocks": 3,
    "settings": [{
        "id": "text-box",
        "type": "text",
        "label": "Heading",
        "default": "Title"
    }],
    "blocks": [{
        "name": "Add Image with Text",
        "settings": [{
                "id": "image",
                "type": "image_picker",
                "label": "Image"
            },
            {
                "id": "link",
                "type": "url",
                "label": "Image link"
            },
            {
                "name": "Text Box",
                "settings": [{
                        "id": "text-box-title",
                        "type": "text",
                        "label": "Heading",
                        "default": "Title"
                    },
                    {
                        "id": "text-box-content",
                        "type": "richtext",
                        "label": "Add custom text below",
                        "default": "<p>Add your text here</p>"
                    }
                ]
            }
        ],
        "presets": [{
            "name": "Call to Action Blocks",
            "category": "CTA button",
            "blocks": [{
                    "type": "select"
                },
                {
                    "type": "select"
                }
            ]
        }]
    }]
}

This is a good tool to check your JSON: https://jsonlint.com/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...