I am developing a Shopify Theme. The structure I have now is (excerpt):
Snippets
custom-message-snippet
Sections
custom-message-section
welcome-page-a-section
welcome-page-b-section
Templates
welcome-page-a-template
welcome-page-b-template
…
Custom message snippet uses settings that are in the custom-message-section, that is:
a) message
b) header text
I’d like for users to be able to add custom-message-snippet to welcome-page-a and welcome-page-b in a way that settings for both are different.
I can not render section ‘custom-message-section" inside welcome pages because it is not possible (and a workaround is nasty).
There are fifty welcome pages. Every welcome page is totally different.
My question is:
How to allow users to use custom-message-snippet in all welcome pages without copying and pasting custom-message-page setting schema to each and every welcome page?
3
Answers
Short: You can’t.
Long: Using storefront 2.0, you end you having blocks, which can be added manually to any template.
combine
custom-message-section
tocustom-message-snippet
combine
welcome-page-w+-template
towelcome-page-template
, you only need to have one template and schema set, the user will control the sections in schema selection.in template, use schema to select the page-content; this, defined by a bunch of if-else /switch statement.
in welcome-page-custom-message-section
create checkbox select schema for custom message to appear or not.
It is possible if you have a little knowledge of Node.js and you’re using the Shopify CLI.
Check the solution here: Shopify Section / Block Schema In A Separate File. It is possible