Snippets and Section Schema

fjorge
Shopify Partner
8 0 1

I'm looking for a way to create a common JSON schema object to share across multiple sections.

 

Things I have tried:

  • Creating a snippet with the "{% schema %} ... json markup ... {% endschema %}" in it but that's not valid.
  • Create a snippet with just the json markup in it. And then within the section having something like:
    "{% schema %} {% include 'snippet-schema-json' %} {% endschema %}"
    But that is also invalid.
  • Using metafields to store the global scheme object and print onto the page. This didn't cause any errors, but all it did was print the text to the page instead of actually registering the section schema fields

 

Is it possible to have schema managed from a central location and used in multiple sections?

"Let's Build Something Great, Together"
Minneapolis, MN
0 Likes
Misterbruce
Shopify Expert
6 0 0

Did you ever figure out a solution? I'm working through the same problem myself. Would love to know if you've fared better than me

0 Likes
 
 

I did this with a block for the page. Well it will depend on what you planning to do, in my case a different Contact form to different pages.

 

{% schema %}
{
"name":"Contact form",
"class":"contact-form",
"blocks":[
{
"name": "pages",
"type":"text-block",
"settings":[
{
"type": "page",
"id": "page_handle",
"label": "Where you want the form?"
}

 

Then you need to add the section to the page code you want and on the customizer add the page so it shows.

 

Well it worked for me. have a try

 
 
 
 
Luis Cardoso
Web Developer at CraftChocolatier.co.uk
0 Likes
Misterbruce
Shopify Expert
6 0 0

Thanks. A bit different than what I'm working on but useful no less, I appreciate the follow-up!

0 Likes