Solved

Where to define block types in schema?

dwightco
Excursionist
21 0 2

Hi all, I always see block types in schema, but I'm not sure where I can define them? Where do make the block definitions? Or does Shopify have block type presets I can look at? Thank you!

dwightco_0-1614744419258.png

 

 

 

Accepted Solution (1)
gina-gregory
Shopify Expert
742 51 211

This is an accepted solution.

Block types are completely custom, so there is no documentation on what block types there are. They are whatever you want them to be, and then you check for that when you want to know the type of block it is.

 

 

"blocks": [
    {
      "type": "page-banner",
      "name": "Page Banner",
      "settings": [{...}]
    },
    {
      "type": "custom-module-x",
      "name": "Custom Module (version X)",
      "settings": [{...}]
    },
    {
      "type": "abc-block",
      "name": "ABC Block Name",
      "settings": [{...}]
    }
]
{% liquid for block in section.blocks
  case block.type
    when 'custom-module-x'
      include 'snippet-custom-module-x'
    when 'page-banner'
      include 'snippet-page-banner'
    when 'abc-block'
      include 'snippet-abc-block' 
  endcase
endfor %}

 

 

View solution in original post

Replies 5 (5)

ZestardTech
Shopify Expert
5393 970 1291

Hello There,

check this one article how to define schema and block types.
https://www.shopify.in/partners/blog/how-to-create-your-first-shopify-theme-section

Want to modify or develop new app, Hire us.
If helpful then please Like and Accept Solution .
Email: support@zestard.com
Shopify Apps URL :- https://apps.shopify.com/partners/zestard-technologies
Custom Modifications Into Shopify Theme | Shopify Private App | SEO & Digital Marketing
dwightco
Excursionist
21 0 2

Hi Pallavi, thanks for your reply.

I know how blocks generally work but I don't know specifically where to find and what "type" in the block parent does. I can't seem to change them and they don't show up anywhere?

Some examples:

select-type.pngcollection-type.png

 

So I know what the blocks inside do, but what does the "type" in the parent means?

And where are those defined? I saw that "collection" type in a theme, but I can't find it in any documentation?

Thanks!

ZestardTech
Shopify Expert
5393 970 1291

Check this one article 

https://github.com/Shopify/starter-theme/blob/master/src/sections/collection-list.liquid

Want to modify or develop new app, Hire us.
If helpful then please Like and Accept Solution .
Email: support@zestard.com
Shopify Apps URL :- https://apps.shopify.com/partners/zestard-technologies
Custom Modifications Into Shopify Theme | Shopify Private App | SEO & Digital Marketing
gina-gregory
Shopify Expert
742 51 211

This is an accepted solution.

Block types are completely custom, so there is no documentation on what block types there are. They are whatever you want them to be, and then you check for that when you want to know the type of block it is.

 

 

"blocks": [
    {
      "type": "page-banner",
      "name": "Page Banner",
      "settings": [{...}]
    },
    {
      "type": "custom-module-x",
      "name": "Custom Module (version X)",
      "settings": [{...}]
    },
    {
      "type": "abc-block",
      "name": "ABC Block Name",
      "settings": [{...}]
    }
]
{% liquid for block in section.blocks
  case block.type
    when 'custom-module-x'
      include 'snippet-custom-module-x'
    when 'page-banner'
      include 'snippet-page-banner'
    when 'abc-block'
      include 'snippet-abc-block' 
  endcase
endfor %}

 

 

dwightco
Excursionist
21 0 2

Thank you so much! I get it now!