Liquid, JavaScript, themes, sales channels
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.
Solved! Go to the solution
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
New Feature: Automatic free shipping discounts
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
Defeat problems ,Learn To Ask Questions The Smart Way
"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.
New Feature: Automatic free shipping discounts
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
Defeat problems ,Learn To Ask Questions The Smart Way
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 %}
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
New Feature: Automatic free shipping discounts
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
Defeat problems ,Learn To Ask Questions The Smart Way
Thanks for clarifying Paul. Its a shame we can't include static sections in .json templates.
@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.
New Feature: Automatic free shipping discounts
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
Defeat problems ,Learn To Ask Questions The Smart Way
User | RANK |
---|---|
25 | |
21 | |
7 | |
6 | |
5 |
Explore the 30-30-30 rule, a dynamic social media strategy for new businesses. Learn how t...
By Trevor Sep 20, 2023Discover how to leverage the often overlooked footer of your ecommerce site to gain custom...
By Skye Sep 15, 2023In this blog, we’ll be shining a light on Shopify Partners, Experts, and Affiliates. Who a...
By Imogen Sep 13, 2023