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
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.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
//encode array to json
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.
Do this way (This is for example)