Solved

Can we create static sections with Online Store 2.0?

timd
Shopify Expert
121 6 74

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.

Accepted Solution (1)
PaulNewton
Shopify Partner
6275 574 1324

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

Save time & money ,Ask Questions The Smart Way


Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org


View solution in original post

Replies 5 (5)

PaulNewton
Shopify Partner
6275 574 1324

"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.

 

Save time & money ,Ask Questions The Smart Way


Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org


timd
Shopify Expert
121 6 74

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 %}

 

PaulNewton
Shopify Partner
6275 574 1324

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

Save time & money ,Ask Questions The Smart Way


Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org


timd
Shopify Expert
121 6 74

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

PaulNewton
Shopify Partner
6275 574 1324

@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.

Save time & money ,Ask Questions The Smart Way


Confused? Busy? Get the solution you need paull.newton+shopifyforum@gmail.com


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Buy Paul a Coffee for more answers or donate to eff.org