Liquid, JavaScript, themes, sales channels
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?
No, block nesting is not 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>
You can do this by calling out a forloop inside the block:
Is it possible to create draggable items in a module within block. I know blocks within blocks is not possible. Is there any other solution to achieve the same effect.
We can achieve this homepage easily by adding blocks in section file. How to achieve the same for inner pages.
You can't currently drag inside of a block but you could add a dropdown where there are different layout styles for the contents in the block that change the css, snippet, etc based on selection.
Come on @Shopify do something about block nesting, it's the end of 2022 - every respectable CMS has this functionality.
Come on @Shopify do something about block nesting, it's the end of 2023 - every respectable CMS has this functionality.
They will never allow it due to simplicity. People like the simplicity of "Customize" for their themes.
Nesting may just add frustration, confusion, more support requests, etc.
Are you ready to take your business to the next level? Look no further than the latest ...
By SarahF_Shopify Apr 15, 2024We’re keeping the ball rolling to make sure you’re always ahead of the game. So buckle ...
By JasonH Apr 8, 2024Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024