PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, July 1, 2022

[FIXED] How to add default URL in Sections Schema

 July 01, 2022     liquid, shopify     No comments   

Issue

I have been trying to create a schema for a dynamic section, and use some predefined default URL for some pages but liquid cannot accept it. This is the schema code:

{% schema %}
{
  "name": "My New Section",
  "class": "homepage-section",
  "tag": "section",
  "settings": [
    {
      "type": "text",
      "id": "section-heading",
      "label": "Section Heading",
      "default": "Default Heading",
      "info": "Meaningful copy in 25 characters or less."
    },
    {
      "type": "url",
      "id": "link-1",
      "label": "Link URL 1",
      "default": "/collections/mycollection"
    }
  ],
  "presets": [
    {
      "name": "My New Section",
      "category": "My Sections"
    }
  ]
}
{% endschema %}

So, for the "type": "url" I try to define the default collection "default": "collections/mycollection" and this is the error message when I try to save the file:

This file contains the following errors: Error: Invalid schema: setting with id="link" default must be a string or datasource access path

I tried some different options without success:

"default": "https://testing.myshopify.com/"

"default": "https://testing.myshopify.com/"

"default": "collections/mycollection"

"default": "collections/mycollection"

Please, let me know if there is anyway to handle it.


Solution

You need to read the documentation regarding the special input type provided by Shopify called URL

According to the documentation, you can only set these 2 URLs by default:

  1. /collections
  2. /collections/all

enter image description here

This is because these are two URLs that are present after the store creates automatically, one is set for all collections list pages and once for all products pages. so Shopify knows these two's have already existed.

So these are two default values that you accept into URL fields into the Shopify schema.



Answered By - Onkar
Answer Checked By - Mary Flores (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing