Sections & Blocks per page

Shopify Expert
60 0 25

Hi all,

I'm playing with the new Sections & Blocks feature in Shopify theme dev. Anybody know if there is support, or a trick, for applying sections to more than just the home page? The "{{content_for_index}}" renders the specified sections on the home page but what if I wanted a different set of sections on a different page? 

And bonus question: With this method, could the settings for, as an example, a map be different on the home page versus a different map section on a different page?

HUGE potential for this feature but curious if it can be implemented to match my mad scientist plans.... 

5 Likes
Shopify Partner
21 0 2

Hey Jonathan, I'm right there with you on this! I'm very new to Shopify, and especially new to this Sections feature that just came out. I just managed to place some sections in a unique custom page template using sections tags, like these:

{% section 'feature-columns' %}
{% section 'slideshow' %}

They look great and can be edited by navigating in the new UI to my custom page. I have two issues that I can't figure out, however: 

  1. I can't drag/drop the sections like I can the homepage (I understand why, because the tags are statically placed in the template, I just don't know how to generate "{{content_for_index}}" type of behavior on a custom page template.)
  2. It looks like you can only have one instance of a given section on a page. For instance, I tried to place two {% section 'feature-row' %} tags in the template, and they just mirrored each other as I edited one or the other. Only work-around I got to work is duplicating a section template, like feature-row.liquid and naming it something like feature-row-2.liquid. Doing that allowed them to have unique content. 

Aside from my experimenting, regarding "content_for_index", I found the info quoted below on the new documentation:

content_for_index is a new global object that contains the content (rendered sections) of the homepage...Templates other than index.liquid do not support adding and removing sections.

The part in bold confuses me because—as explained above—I did get a custom page template to have sections. In the near future, I'm hoping to see the documentation expand to show more possibilities and maybe explain things a little better. But like you, I'm stoked for this new feature.

1 Like
Shopify Expert
60 0 25

You are correct in all your findings and I have played around with this stuff a lot more since my post. Sections actually CAN be duplicated, with each instance having unique data, but only on the home page currently. So to use your "slideshow" section example here is what I did:

  • Created a "slideshow-home.liquid" section
  • Created a "slideshow-1.liquid" section
  • Created a "slideshow-2.liquid" section
  • Created a "slideshow-3.liquid" section
  • All of these have the exact same "schema" JSON except for their names. The "home" section though includes a "presets" config in its schema so it can be selectable on the home page. This same section can be added multiple times, and configured uniqely, to the home page.
  • I created a "section-slideshow.liquid" snippet to have the actual display rendering code and included it in each section. This way I don't have to duplicate any display code. If we could include "schema" JSON in a snippet in the future that would be even better.
  • I can then place the numbered instances of this section in various other places in the theme liquid and then customize them using the theme editor.

Make sense? Thoughts?

0 Likes
Shopify Partner
21 0 2

Hmm I didn't have to do any of that JSON/schema stuff (happily, because I don't really know it yet). I just dropped something like this in a (non-homepage) custom page template and Sections just worked on their own. I AM using the new section-ready Debut theme, maybe that's why it "just works"?

<div id="mission">
  {% section 'feature-row' %}
  {% section 'feature-row-2' %}
</div>

 

0 Likes
Shopify Expert
60 0 25

The JSON/schema stuff is in the 'feature-row' section code

0 Likes
Shopify Partner
21 0 2

OK I get it! So you removed all the display rendering schema from each duplicated section template, put it into a single snippet file, and then put one of these in each instance of a duplicated section template:  {% include ‘snippet name’ %}

On another test, I just placed the same two section tags

  {% section 'feature-row' %}
  {% section 'feature-row-2' %}

into a different page template and they display the same content as the other page. I thought they might be unique to each page, but no. They behave much like the header/footer sections. So going forward I think I'll use a more specific naming convention for each duplicated section template, e.g. "slideshow-aboutpage-1.liquid" "slideshow-aboutpage-2.liquid" etc and so on.

All this is great to be able to utilize sections anywhere, but when they're not on the homepage, they don't have that "drag/drop/reorder" functionality, which would be ideal. As you mentioned, that has something to do with the "presets config", which I am not smart enough to figure out how to make work on a global scale, if that's even possible. I know presets is a homepage-specific feature.

Anyhow, I'm just thinking out loud at this point. Thanks for bearing with me.

0 Likes
Shopify Expert
60 0 25

Yeah, at this point you seem to grasp all that we can do at this point. There is no drop/drop/reorder on any page other than the home page right now. I hope this will change one day (soon). 

0 Likes
Shopify Partner
21 0 2

Jonathan, I attampted to create a snippet with only the schema code, but upon saving it, I get 

This file contains the following errors:

  • Line 1 — Liquid syntax error: Unknown tag 'schema'

How did you do it?

0 Likes
Shopify Expert
60 0 25

I tried the same thing :)   schema tag and its JSON must reside in the section code. The code that renders the section, the display code, will be in a snippet included by the section code. 

0 Likes
Shopify Partner
30 0 13

Man it is almost depressing to read this thread :)  I ran into the same problem creating a 'Team Members' section for a client.  Figured I could just have one section for the Team Members listing page and one section for the Team Member details page.  I tried creating multiple page templates ( one per member ) but even that doesn't cut it.  I am going to have to create a page.<member-name>.liquid for every member and a sections/team-member-<member-name>.liquid to go along with it.

If you look in the settings_data.json you can see that for the homepage it uses unique id's to store the sections and their data but for anything else it just stores them as the section name.  This makes me think there is no way to do it :/

0 Likes