Ad

Add Dynamic Content In {% Schema %} Section For Shopify Theme

- 1 answer

According to Shopify theme tutorial https://help.shopify.com/themes/development/theme-editor/settings-schema

files, we can define theme setting through set {% schema %} part like the following example:

{% schema %}
{
  "name": "Line",
  "class": "index-section",
  "settings": [
    {
      "type": "radio",
      "id": "small_line",
      "label": "Correct Gap",
      "options": [
        {
          "value": "none",
          "label": "None"
        },
        {
          "value": "gap1",
          "label": "Different Gap"
        }
      ],
      "default": "none"
    }
  ],
  "presets": [
    {
      "name": "Line",
      "category": "Design",
      "settings": {
      }
    }
  ]
}
{% endschema %}

My question if there is a way we can set this settings to be dynamic in the schema part like define "small_line" options as a variable in the above example, something similar to the following

{% schema %}
{
  "name": "Line",
  "class": "index-section",
  "settings": [
    {
      "type": "radio",
      "id": "small_line",
      "label": "Correct Gap",
      "options": MY_OPTIONS_VAR,
      "default": "none"
    }
  ],
  "presets": [
    {
      "name": "Line",
      "category": "Design",
      "settings": {
      }
    }
  ]
}
{% endschema %}
Ad

Answer

No you can't add any liquid code in your schema object.

Everything there needs to be entered as static information.

Ad
source: stackoverflow.com
Ad