Static Sections with OS2.0

Solved
timd
Shopify Expert
81 3 28

I'm wondering if theres a way to create static sections with Online Store 2.0.

Previously this was created by adding a section with {% section 'X' %} to a template. But now that sections are defined in a .json template, it doesn't appear that theres any way to add a static section to a json template which pulls data saved in settings_data.json.

For example, I have a section that was visible on the collection page and product page. Previously I could add the section to each template and it would share the same data. But now if I add the section to collection.json and product.json templates, the data is separated and my client would have to duplicate the section data across the 2 templates.

0 Likes
PaulNewton
Shopify Partner
3128 195 576

"static" sections have no presets, there's also whether the setting should be move to global settings.

Section files must define presets in their schema to support being added to JSON templates using the theme editor. Section files without presets should be included in the JSON file manually, and can't be removed usi....

Alternatively use standard liquid templates and not JSON templates for those pages that need this shared setting functionality.

 

Problem Solved? ✔️Accept and ? Like the solution so you can help others.
Buy me a coffee ☕ paypal.me/paulnewton or donate to eff.org
Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com
0 Likes
timd
Shopify Expert
81 3 28

Hi Paul,

I have tried adding a section with no present schema to a JSON template but it doesn't seem to pull/save data from the global settings_data.json file.

For example, the section data in settings_data.json for promo-text data looks like this:

 

"promo-text": 
  { 
    "type": "example-1", 
    "blocks": { 
      "684a0848-9d15-4382-9bdb-75b8de3069a2": { 
        "type": "promo", 
        "settings": { 
          "content": "Example",
        }
      }
   }, 
  "block_order": [ "example-1", ], 
  "settings": { } 
}

 

And in the collection.json is:

 

{
  "sections": {
    "collection": {
      "settings": {
      }
    },
    "promo-text": {
      "type": "promo-text",
      "settings": {
      }
    }
  },
  "order": [
    "collection",
    "promo-text"
  ]
}

 

If I remove the 'settings' attribute from the promo-text object, the theme edit just addeds it again. Is there another attribute or something that I'm missing which tells the section to pull data from the global settings?

The section code is:

 


{% schema %}
  {
    "name": "Promo Text",
    "max_blocks": 10,
    "settings": [
    ],
	"blocks": [ 
	    {
	      "type": "promo",
		  "name": "Text Bubble",
		  "settings": [
			  {
				  "type": "textarea",
				  "id": "content",
				  "label": "Content",
			  }
		  ]
	  } 
    ]
  }
{% endschema %}

 

0 Likes
PaulNewton
Shopify Partner
3128 195 576

This is an accepted solution.

if pulling info from global settings they must be IN the LIQUID section itself not a json property referenced in a JSON template

Problem Solved? ✔️Accept and ? Like the solution so you can help others.
Buy me a coffee ☕ paypal.me/paulnewton or donate to eff.org
Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com
0 Likes
timd
Shopify Expert
81 3 28

Thanks for clarifying Paul. Its a shame we can't include static sections in .json templates.

0 Likes
PaulNewton
Shopify Partner
3128 195 576

@timd wrote:

Thanks for clarifying Paul. Its a shame we can't include static sections in .json templates.


Is a shame and it's a confusing terminology problem, so you can add a shared "static" section between templates by removing the presets but it will not behave like a "static" section on the homepage /wrist.

Problem Solved? ✔️Accept and ? Like the solution so you can help others.
Buy me a coffee ☕ paypal.me/paulnewton or donate to eff.org
Confused? Busy? Buy a custom solution paull.newton+shopifyforum@gmail.com
0 Likes