skip to Main Content

I’m wondering if nested block on shopify schema is possible. I search on it but I can’t find an answer. Please help me out if anyone knows how to do it.

Here’s my schema

"blocks": [
  {
    "type": "block_main",
    "name": "Block Main",
    "settings": [
      {
        "type": "text",
        "id": "block-name",
        "label": "Quote"
      },
      {
        "type": "url",
        "id": "block-link",
        "label": "URL"
      }
    ],
    "blocks": [
      {
        "type": "sub_block",
        "name": "Sub Block",
        "settings": [
          {
            "type": "text",
            "id": "sub-block-name",
            "label": "Quote"
          },
          {
            "type": "url",
            "id": "sub-block-link",
            "label": "URL"
          }
        ]
      }
    ]
  }
]

3

Answers


  1. No it’s not possible. ( sadly )

    You will have to use a different logic in order to create nested blocks.

    For example you can use a link_list field and use the text and URL from the links to populate the information you are looking.

    Login or Signup to reply.
  2. I think this is nothing but just a way to represent data communication.
    To do this I always create a associative array then convert it into JSON. Look this sample PHP code

    //Make associative array

    $data = array("blocks" => array("type" => "block_main", "name": "Block Main","settings" => array("0" => array("type" => "text", "id": "block-name", "label": "Quote"), [1] => array(type": "url", "id": "block-link", "label": "URL")), "blocks": "type": "sub_block", "name": "Sub Block", "settings": array("0" => array("type": "text", "id": "sub-block-name", "label": "Quote"), "1" => array(type": "url", id": "sub-block-link", "label": "URL"))))
    

    //encode array to json

    $json = json_decode($data)
    

    And the same would be happening on server side, When we send Post request. It would also render the nested JSON request to associative array then react on the data.

    Login or Signup to reply.
  3. Do this way (This is for example)

    {
       "name": "FAQs",
       "settings": [
         {
           "id": "dev-faq-title",
           "type": "text",
           "label": "FAQ Title",
           "default": "Frequently Asked Questions"
         }
       ],
       "blocks":[
         {
           "type": "block-1",
           "name": "Block 1",
           "settings": [
             {
               "type": "text",
               "id": "title",
               "label": "Title"
             },
             {
               "type": "text",
               "id": "accordion-title",
               "label": "Accordion Title"
             }
           ]
         },
         {
           "type": "block-2",
           "name": "Block 2",
           "settings": [
             {
               "type": "text",
               "id": "title",
               "label": "Title"
             }
           ]
         },
         {
           "type": "block-3",
           "name": "Block 3",
           "settings": [
             {
               "type": "text",
               "id": "title",
               "label": "Title"
             }
           ]
         }
       ],
       "presets": [
       {
         "category": "Text",
         "name": "Top Bar"
       }
     ]
    
    }
    
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search