Hey everyone!
I have been trying to include some blocks inside a block( I am not really sure if it is possible or not though) but could not manage to do that. If it is possible to do, what am I doing wrong here?
Here is my code:
{% schema %}
{
"name": "FAQ Heading",
"settings": [{
"type": "header",
"content": "Heading and Description"
},
{
"type": "text",
"label": "Title",
"id": "heading"
}
],
"blocks": [{
"type": "block-1",
"name": "Block 1",
"settings": [{
"type": "text",
"label": "Your Text Here ",
"id": "text"
},
{
"type": "url",
"label": "Your Link Here",
"id": "call-to-action"
}
],
"blocks": [{
"type": "block - 1 - 1 ",
"name": "Block alt",
"settings": [{
"type": "text",
"label": "youretx here",
"id": "text-f"
}]
}]
}]
}
{% endschema %}
You can not nest blocks but you can have more block types:
"blocks": [
{
"type": "block-1",
"name": "Block 1",
"settings": [...]
},
{
"type": "block-2",
"name": "Block 2",
"settings": [...]
}
]
Hello @Mircea_Piturca, thanks for the answer. But this is not what I am looking for. I already know this. What I mean is that, let's say, including blocks inside a nestetd block. For example, there is block-1, right? I would like to include some other blocks inside that nested block "block-1". Is that possible?
You can do a loop with a conditional:
{% for block in section.blocks %}
{% if block.type == 'type-1' %}
...
{% elsif block.type == 'type-2' %}
...
{% endif %}
{% endfor %}
You can also do some cool things with map. Depends what you are looking for.
you have used condition but i want to access both somthing like this
<section>
<div>
{% for block in section.blocks.image-1 %}
<div>{{ block.image-1.settings.text }}</div>
{% for block in section.blocks.image-2 %}
<div>{{ block.image-2.settings.text }}</div>
{%endfor%}
{%endfor%}
</div>
</section>
User | Count |
---|---|
23 | |
19 | |
18 | |
17 | |
16 |