180k views
4 votes
How can you access a section file's settings outside of that section?

a. Using, for example, the {% section.settings.setting_id %} Liquid drop anywhere
b. Using, for example, the {% section[header].settings.setting_id %} Liquid drop anywhere
c. Passing the section's setting into a snippet file using a custom variable
d. You can't—it's best to use global settings for theme-wide options.

User Kothar
by
8.5k points

1 Answer

2 votes

Final answer:

To access a section file's settings outside of that section in Shopify, you should pass the setting into a snippet file using a custom variable as direct access is not possible with the Liquid template language.

Step-by-step explanation:

The question is about accessing a section file's settings in Shopify Liquid templates outside of that section. The correct method is c. Passing the section's setting into a snippet file using a custom variable. You cannot directly use section settings outside of their own section with the Liquid template language. Instead, you should pass the specific setting you want to use into a snippet via a custom variable. This approach allows the snippet to access the value of the setting, as snippets are included within your Liquid templates or other sections.

User Fady Sadek
by
7.7k points