0 like 0 dislike
11 views
asked in Sections Anywhere by

I'm trying to add blocks to my section but I am getting an undefined error when rendering the variable.

Please log in or register to answer this question.

1 Answer

0 like 0 dislike
answered by

Adding blocks in Sections Anywhere is a bit different than in native Shopify sections at the moment.

To create a block in Sections Anywhere, simply add an attribute of repeatable to any field.  

    {

      "type": "color",

      "id": "atb_paragraph_color",

      "label": "Paragraph Color",

      "default": "#4a4a4a",

      "repeatable": "block",

      "info": ""

    },

The name you give to the repeatable attribute becomes the name of the group.   In this case, the name is "block".

You can take it a step further and add block types like this:

    {

      "type": "select",

      "id": "block_type",

      "label": "Block Type",

      "info": "",

      "default": "",

      "options": [

        {

          "value": "text",

          "label": "text"

        },

        {

          "value": "image",

          "label": "image"

        },

        {

          "value": "video",

          "label": "video"

        },

        {

          "value": "product",

          "label": "product"

        },

        {

          "value": "collection",

          "label": "collection"

        },

        {

          "value": "html",

          "label": "html"

        }

      ],

      "repeatable": "block"

    },

This will allow you to add different kinds of blocks to the same area.  If you are using block types and you want a field to be limited to a specific block type, you would add a conditional attribute to the field like this:

    {

      "type": "text",

      "id": "atb_block_heading_text",

      "label": "Heading Text",

      "default": "Talk about your brand",

      "repeatable": "block",

      "info": "",

      "conditional": "block_type:text"

    },

This field will only display if "text" has been chosen from the block type drop down.

Ask questions and receive answers from our expert developers and other members of the community.
...