Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
So I did a conversion of my site to OS 2.0 a while back. One of the intriguing things about OS2 is the changes made to section templates, with the ability to have a section repeat itself in multiple instances.
However, in practice I have found either an incredibly stupid limitation, or an unintuitive interface.
I have a page template called bio.page.json. Inside that renders the bio-section.liquid section file. I have 20-30 "bio page" templates. However the section file is not "reusable" on a per page basis. Once the customizer content is edited for that section it applies to every single page with the bio template. I thought one of the use cases of section everywhere was to eliminate the need to create a ton of files for reusable content.
Am I missing something? I want unique content in each section per page!!!
I've used this without issue so it should work.
Are these sections you've created yourself? It's possible you missed some attributes from the main section file div, like:
<div data-section-id="{{ section.id }}" data-section-type="header-section">
Or
<section class="section--featured-collection" id="section-{{ section.id }}">
Though i'd have thought these would be autofilled if not present. What does the data structure of your new .json template look like? If it's correctly creating unique IDs you should see something like
Where each key inside the sections object has a unique name where the data for that section is stored.
@nickkos Did you find a fix for this?
It seems to me the issue is still present, I have one collection.json file which is the default collection template, if I go into customise and add a section to one of my collections it then appears on all collections which are using the collection.json file as their template.
I was expecting with 2.0 if I add a section to any page, product, collection it would be specific to that page and not specific to the template.
All of my sections have a unique ID like:
data-section-id="{{ section.id }}"
I'm also not including them statically, and I can add them to any page
In my .json template file, I can see the section id and name, as per your comment @iDoThemes
Seems to me as the data is stored in a single template file, its specific to that template and not the individual pages that use that template, which is basically how thing worked < 2.0. Which is a shame!
This also seems to be the case using the default Dawn theme, if you create two pages that use the same default page template, they inherit the sections added from each other. But if you add a contact page which uses the contact template, then the sections are separate.
Is there a fix for this? Or does Shopify plan to fix this? I guess once metafields are rolled out for collections, I can just use those.
Within the theme customizer you can create a new template - for example, collections-alternate and then add the block only to that. Then you can assign certain collections to use that template.
@cdennington Did you find a solution for this?
Because in my experience this is a really dumb situation where you end-up with endless templates, one for every page where you want page-specific content - which is what 95% of website is!
What we want is endless pages, not endless templates.
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024