Dawn theme questions regarding section availability

Hey guys -

Been playing around with Dawn this evening. It’s quite exciting. However, I can’t figure something out, and can’t figure out where in the new docs this is covered.

Firstly, what determines sections in the new .json theme file that can’t be removed in the customiser? Like on a product page, we have:

Product information and Product recommendations, neither of which can be deleted. But any other section I add can be deleted. How do I create a section on a product template (for instance), that can’t be deleted by someone making changes in the customiser?

Secondly, when I look at the sections available to me on other pages (say, the Homepage), I can’t see the Product recommendations section as being available. I know this makes sense, but why isn’t it available? I sort of figured it would be to do with the templates part in the schema (as here: https://shopify.dev/themes/architecture/sections/section-schema#templates) saying the Product recommendations could only be used in the product template - except that’s not in the schema in that section! What determines that collage.liquid will be available everywhere, and pickup-availability.liquid isn’t? Am I missing something?

Am sure I’ll have more questions (and is design the best place to post, or “New Online Store Design Experience” - feel free to move this if it make sense!), but looking good so far.

Thanks!
"

@iamben how did you add Dawn? I’m having a hard time getting it to load

which part do you have a problem with?

@kaymay - create a new development store.

@Majagar - are you asking me? I’ve explained a couple of times. It’s not really a problem; I’m just trying to understand it and it’s not clear from the docs alone.

@iamben Yea, you’re right it’s a bit unclear, I still believe something’s missing

'cause it does not make sense that the shop admins are not updated

Anyone have any luck with this? @iamben do you have any documentation references for Dawn? I’m trying to understand the new structure, I don’t really get how the JSON templates work yet.

Honestly, Kind of in the same boat on reference material, there seems to be whole bunch of new features and deployment but no real current documentation.

I asked Shopify support, but have been advised that there is non avaliable for my request at this time.

Guys, what’s your problem?:slight_smile: :slightly_smiling_face: It works the same as before. If you want to see the section available on the home page (or on any page with recent changes) , then you need to add the “presets” field for the schema in the section. If this field is not added, then the section will not be available for dynamic adding and it will be static. A static section cannot be deleted via the customizer

Ok, I’ll bite! But only because I still don’t get it and appreciate you answering (thanks!) :slightly_smiling_face:

So here’s the contents of my index.json (as per Dawn) -

{
  "sections": {
    "image_banner": {
      "type": "image-banner",
      "blocks": {
        "heading": {
          "type": "heading",
          "settings": {
            "heading": "Talk about your brand"
          }
        },
        "button": {
          "type": "buttons",
          "settings": {
            "button_label_1": "Shop all",
            "button_link_1": "shopify:\/\/collections\/all",
            "button_style_secondary_1": false,
            "button_label_2": "",
            "button_link_2": "",
            "button_style_secondary_2": false
          }
        }
      },
      "block_order": [
        "heading",
        "button"
      ],
      "settings": {
        "desktop_text_box_position": "flex-end",
        "color_scheme": "background-1",
        "stack_images_on_mobile": true,
        "adapt_height_first_image": false
      }
    },
    "featured_products": {
      "type": "featured-collection",
      "settings": {
        "title": "Featured products",
        "collection": "",
        "products_to_show": 4,
        "show_view_all": true,
        "swipe_on_mobile": false,
        "image_ratio": "adapt",
        "show_secondary_image": false,
        "add_image_padding": false,
        "show_vendor": false
      }
    },
    "image_text": {
      "type": "image-with-text",
      "blocks": {
        "heading": {
          "type": "heading",
          "settings": {
            "heading": "Image with text"
          }
        },
        "text": {
          "type": "text",
          "settings": {
            "text": "

Pair text with an image to focus on your chosen product, collection, or blog post. Add details on availability, style, or even provide a review.<\/p>"
          }
        },
        "button": {
          "type": "button",
          "settings": {
            "button_label": "Button label",
            "button_link": ""
          }
        }
      },
      "block_order": [
        "heading",
        "text",
        "button"
      ],
      "settings": {
        "height": "adapt",
        "color_scheme": "background-1",
        "layout": "image_first"
      }
    }
  },
  "order": [
    "image_banner",
    "featured_products",
    "image_text"
  ]
}

Here’s a grab of my index / home in ‘Customize’ -

That makes sense, I can see how it relates to the json. Now if I click add section I see:

None of these are referenced in index.json - so let’s look at some of the sections themselves (because how does it know to show all those?). Here’s a short one, custom-liquid.liquid -

{{ section.settings.custom_liquid }}

{% schema %}
{
  "name": "t:sections.custom-liquid.name",
  "tag": "section",
  "class": "spaced-section",
  "settings": [
    {
      "type": "liquid",
      "id": "custom_liquid",
      "label": "t:sections.custom-liquid.settings.custom_liquid.label"
    }
  ],
  "presets": [
    {
      "name": "t:sections.custom-liquid.presets.name"
    }
  ]
}
{% endschema %}

Ok, so I can’t see anywhere in there that say where this can and can’t be used (as per https://shopify.dev/themes/architecture/sections/section-schema#templates - “templates”: [“article”, “index”, “page”, “product”] - for instance). So maybe this can be used everywhere, right, which is why we see it in that list on the index?

But then look at the liquid for product-recommendations.liquid -


{% javascript %}
  class ProductRecommendations extends HTMLElement {
    constructor() {
      super();

      const handleIntersection = (entries, observer) => {
        if (!entries[0].isIntersecting) return;
        observer.unobserve(this);

        fetch(this.dataset.url)
          .then(response => response.text())
          .then(text => {
            const html = document.createElement('div');
            html.innerHTML = text;
            const recommendations = html.querySelector('product-recommendations');
            if (recommendations && recommendations.innerHTML.trim().length) {
              this.innerHTML = recommendations.innerHTML;
            }
          })
          .catch(e => {
            console.error(e);
          });
      }

      new IntersectionObserver(handleIntersection.bind(this), {rootMargin: '0px 0px 200px 0px'}).observe(this);
    }
  }

  customElements.define('product-recommendations', ProductRecommendations);
{% endjavascript %}

{% schema %}
{
  "name": "t:sections.product-recommendations.name",
  "tag": "section",
  "class": "spaced-section",
  "settings": [
    {
      "type": "header",
      "content": "t:sections.product-recommendations.settings.header__1.content",
      "info": "t:sections.product-recommendations.settings.header__1.info"
    },
    {
      "type": "text",
      "id": "heading",
      "label": "t:sections.product-recommendations.settings.heading.label",
      "default": "You may also like"
    },
    {
      "type": "header",
      "content": "t:sections.product-recommendations.settings.header__2.content"
    },
    {
      "type": "select",
      "id": "image_ratio",
      "label": "t:sections.product-recommendations.settings.image_ratio.label",
      "default": "adapt",
      "options": [
        {
          "value": "adapt",
          "label": "t:sections.product-recommendations.settings.image_ratio.options__1.label"
        },
        {
          "value": "portrait",
          "label": "t:sections.product-recommendations.settings.image_ratio.options__2.label"
        },
        {
          "value": "square",
          "label": "t:sections.product-recommendations.settings.image_ratio.options__3.label"
        }
      ]
    },
    {
      "id": "show_secondary_image",
      "type": "checkbox",
      "default": false,
      "label": "t:sections.product-recommendations.settings.show_secondary_image.label"
    },
    {
      "id": "add_image_padding",
      "type": "checkbox",
      "default": false,
      "label": "t:sections.product-recommendations.settings.add_image_padding.label"
    },
    {
      "id": "show_vendor",
      "type": "checkbox",
      "default": false,
      "label": "t:sections.product-recommendations.settings.show_vendor.label"
    }
  ]
}
{% endschema %}

No mention of templates in this one either, right? But this section isn’t in the list on the index page.

Why?!!

Genuinely appreciate the help - I’m sure I’m missing something simple/obvious - but I’ve had a lot of late nights recently and it’s not sinking in…

None of these are referenced in index.json - so let’s look at some of the sections themselves (because how does it know to show all those?). Here’s a short one, custom-liquid.liquid -

"presets": [
    {
      "name": "t:sections.custom-liquid.presets.name"
    }
  ]

This code indicates that the section will be available for adding to the pages

1 Like

Ok, so I can’t see anywhere in there that say where this can and can’t be used (as per https://shopify.dev/themes/architecture/sections/section-schema#templates - “templates”: [“article”, “index”, “page”, “product”] - for instance). So maybe this can be used everywhere, right, which is why we see it in that list on the index?

in the templates attribute, you can specify which templates you want to display this section for. For other templates, this section will not be available in the dropdown list

Ahhhh @Slava_Maksimov you’re a star, thank you! :star: That’s connected the dots for me!

So pretty much:

  • Anything with a ‘preset’ in the section schema is available anywhere.
  • The ‘templates’ part (as well as ‘preset’) then restricts this section from being added anywhere but places the ‘template’ part specifies.
  • Everything else is a static section (as before) and can be referenced in the JSON (or other sections).
  • And then as I’ve just tested, adding a ‘templates’ part to the section schema stops it showing up in ‘Customize’ even if it’s hard coded in the JSON (tested with product recs and the product.json).

Hope that summary helps anyone else who’d twisted themselves in knots!

3 Likes

@iamben @Slava_Maksimov thank you so much for this contribution.

Following your steps I’ve been able to get a custom_liquid field added within the “product information” (main_product.liquid) section so I can add custom code within the product block, but I can’t get it to actually render.

It renders fine outside of the product block (e.g. if just add a custom liquid section to the product template) but I can’t for the life of me get it to render inside the product info block.

I’m guessing I need to reference it within the ProductInfo- div but that’s a little beyond me :disappointed_face:

any help would be most appreciated!

I also ran into this, as the documentation was not very clear.

https://shopify.dev/themes/architecture/sections/section-schema#presets

Section presets are default configurations of sections that allow merchants to easily add a section to a JSON template through the theme editor.

To me, presets read as “default configurations”, not a requirement to give json templates access to editable sections.

The docs could definitely be more clear.