All Section Edit on Shopify Are Global - Shopify Debut Theme Customization - shopify

I tried following this guide to create an alternative template for customization.
https://shopify.dev/tutorials/customize-theme-create-alternate-templates
However, every single section edit I makee are global.
For example: I have two page template: pages.alternative1.liquid and pages.alternative2.liquid
Whenever I edit a section on a page with pages.alternative1.liquid, the same
edit affects the same section on pages.alternative2.liquid as well. Is this normal behavior from
Shopify? How should I edit the page then so that a change in one section
doesn't affect all template?
*Note: I am editing the Debut default theme
using Shopify editor: Theme => Customize
Best Regards

Yes this is a normal behavior.
Static sections ( they are the section that are called like so {% section 'your section' %} ) share content between them. This means that if you edit one anywhere it will update everywhere you use it.
On another hand section that are used on the homepage via the {{content_for_index}} tag are dynamic and you can create the same section with different content. (but only on the homepage or where the tag in question is present)
So if you like to have different content on the page a single section will not do you any good. You can create multiply sections with different names in order to use them on different pages, but if you have 5-10+ page it's not a viable option, since it will become too much of a cluster of section files.

Related

Is there any way to instantiate multiple static sections within a page for Shopify?

I'm fairly new to liquid and Shopify development, but I'm making my way through. I've hit a snag where it seems like what I want to accomplish isn't possible. I'm making a static article page that's primarily HTML, but scattered throughout, I'd like to include instances of a relevant "You Might Like" section to display products.
<HTML>
{% section 'youMightLike' %}
<HTML>
{% section 'youMightLike' %}
I've tried adding a "presets" in the schema tag, and while that allows my section code to be placed anywhere on the homepage and function the way I think it should, my static page only allows for one collection to be chosen (which is then applied to every section on the page).
I've also tried adding blocks to the schema so I could just choose the collection in the block, but that seems to consolidate all the {% section 'youMightLike' %} lines across my entire page.
Am I thinking about this the right way, or is there something else I should be looking into?
Provided your theme is Online Store 2.0 capable, all you need is a unique page template and then you can just add whatever sections are necessary via the customizer.
If it's just a general page or what have you, break your HTML into a section or sections you can include on the page and then you can move around as needed https://shopify.dev/themes/architecture/sections
If your theme isn't 2.0 capable, then you can just create additional sections by modifying them slightly so they're unique. Just copy the section and then modify the name somehow so it's not the same.

Using static and dynamic version of the same template in shopify

I was trying to test the limitations of the Shopify's sections and I was left facing an issue.
Whenever I included one or more static section of a type in the homepage, if there were already dynamic sections of that same type, the one inserted later in the page would show up as a blank whitespace.
Is it not possible to use a static and a dynamic version of the same section in the same template?
For example, making index.liquid
{% section 'slideshow' %}
{{ content_for_index }}
Where settings_data.json contains a 'slideshow' in the sections.
I'm not sure I follow you.
When you use a static section the information for the section is saved in the settings_data.json file. So when you use that section any where else it will use the same information that was entered.
When you use a dynamic section that information is saved in settings_data.json once again but the content for each sections is different and you can have different content for the same section.
That said when you use a static section and dynamic section together the content between them is NOT shared. So when you use a dynamic section that is set as a static section the content will not be passed from the static section to the dynamic section, so that's why your section is blank.
I assume this is the issue you are describing.

Where is the shopify editable html?

In a traditional website I would simply open the 'contact' page and add the line then upload. But i'm having difficulty understand the multiple components of shopify's theme, sections, snippets.
So my question is if I want to add a simple text line say in the homepage, where would I add this html?
It depends entirely on the theme you are using. A lot of modern themes have draggable sections which can be accessed via Themes - Customize.
If your theme doesn't have this functionality, or any functionality to add text to the homepage, I'd be surprised. But if you need to edit it by editing the code directly you can access the pages via Themes - Actions - Edit Code. The homepage will usually have a name of index.liquid.
Rather than just adding your text in there, though, I recommend you learn how to add snippets and sections to your website. It makes future edits much easier and doesn't take long at all to learn.
The beginner's guide to building shopify themes with sections
Shopify: Theme Sections

Creating a secondary index page with identical sections as primary index page but different content?

I'm attempting to create a secondary index page for a theme that I'm working on. It would have the same sections as the primary index page, but with different content. I don't mind hardcoding this instead of it being editable from theme editor.
I've created a new index template called secondary, and copied the code from index.liquid into it. Everything shows up fine.
Then I tried to create a new block in the settings_data.json, right under content_for_index called content_for_secondary, but trying to call it in my new page template isn't working.
I've looked all over for documentation but I can't seem to find exactly how Shopify is handling sections in the settings_data.json and how I can create a new array of sections to call in an alternate template.
Has anyone had any experience with this?
You can't change {{ content_for_index }} it's a global variable. You can read more about it here.
Therefore {{ content_for_secondary }} isn't actually anything, this is why nothing is rendered.
Depending on what you are trying to achieve I think you are best off creating the index sections as statically included sections using {% section 'foobar' %} This way the content on the homepage will still be largely editable. You won't however be able to adjust their order in the theme settings. Check out the link above it will tell you all you need to know.
You might create a page template, for example called secondary_home.
Then, duplicate available sections for homepage (do not use the same or content will be the same), and include them in your new template.
Create a page using the template you created.
Load page in "Customize theme" then set settings for each sections.
Please note that this is only possible with statics sections as dynamic ones are only available for home.

Piranha CMS customisation

A few questions on customisation with Piranha CMS.
Is there a way to create additional custom site-wide items similar to those from the site helper? http://piranhacms.org/docs/api-reference/site-helper
e.g. to be able to set a phone number used throughout the site but still editable in the settings section of the manager.
Is is possible to create additional custom items for a page, e.g. page subtitle, and for those to appear in the Information section of page editing? Creating a region for say a page subtitle seems overkill.
Is it possible to create a custom page type with a region that is a collection of HtmlRegions or similar? e.g. for the purpose of managing a set of FAQs or similar enumerated content?
Is is possible to define custom settings properties for a page type?
Yes, you can add regions to your site in the same way as with page types under Settings > Sites. You then add content for them under Content > Pages > Edit Site.
You can add simple text properties on the page type. They will be shown as single line text inputs under Properties when editing the page.
No native support, however the region body can be anything that can be serialized to JSON so you have to handle this in the edit view for your region.
There is no support for injecting fields into the page settings, however if it's important you can override the whole edit view for pages and do anything you like by placing a copy of the view in the manager area in your local project. You can find the views in the github repo in the 2.2.5 branch.
Regards
HÃ¥kan