PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, June 30, 2022

[FIXED] How To Enable Block Inside Fifty Different Sections Without Copying Meta Code?

 June 30, 2022     shopify, shopify-api, shopify-template     No comments   

Issue

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?


Solution

combine custom-message-section to custom-message-snippet

combine welcome-page-\w+-template to welcome-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.

{% section "welcome-page-custom-message-section" %}
{% section "welcome-page-content" %}

in welcome-page-custom-message-section

{% render "custom-message-snippet" with "string from welcome-page-section schema " %}

create checkbox select schema for custom message to appear or not.



Answered By - Charles C.
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing