Hi. I have a question about theme development.
Is it possible to access section data outside section template?
For example:
I have a copyright text defined in the sections/footer.liquid. The saved data goes to the config/settings_data.json. Now I would like to use that fields data in, let's say, snippets/sidebar.liquid. Is this possible?
I was thinking something like this in the sidebar.liquid:
{%- assign section_data = settings.sections['footer'] -%}
{{ section_data.settings.text_copyright }}
...but that is clearly not working.
Thanks in advance.
Hey,
I have the same question. Can I access the settings from a section (ex: sections/header.liquid) in a template (ex: templates/collection.liquid)?
Maybe someone will help us soon 🙂
So, I've done some research and it seems we cannot do that:
The global settings object (which contains the values of settings defined in settings_schema.json) is available within sections, but you cannot access setting values of sections (for example, section.settings) outside of those sections.
https://help.shopify.com/themes/development/theme-editor/sections#settings
So, we can move that setting from the {% schema %} on that specific section to the settings_schema.json file.
Hi Horas, what do you mean by moving the setting from the section to the settings_schema.json? To be more specific, I have Careers page, and I have added careers-template section with {%schema%} to that page. Now I have to create another page Apply For Job and in that page I should make use of the careers section which I have created in the careers-template. I have no idea how to achieve this...
Hi Dimitar,
I mean that you transfer those page-specific settings to the global settings, in order for you to access those from every page.
If you also want to use certain blocks from your Careers page in your Apply For Job page, maybe the best thing to do is to use snippets and include those also in the later.
Hi Horas,
Sorry to bother you, but so far it seems like you are the only one who can help me.
Can you by some chance provide an example on how to achieve this, some documentation or smth..
I don't know how to transfer those page-specific settings to the global settings, and I am not quite sure how using a snippets will help me...
Thanks in advance.
Hi Dimitar,
You can find more details in the documentation: https://help.shopify.com/en/themes/development/theme-editor/settings-schema
This is also helpful: https://help.shopify.com/en/manual/using-themes/change-the-layout/theme-settings
Hi! I have the same issue here, i saw you resolved your issue - could you help me out? https://community.shopify.com/c/Shopify-Design/use-setting-of-a-section-outside-of-section/m-p/10154...
User | RANK |
---|---|
220 | |
53 | |
50 | |
29 | |
28 |