uicrooks / shopify-theme-lab

Shopify theme development environment using Liquid, Vue and Tailwind CSS. Built on top of Shopify CLI ๐Ÿงช
https://uicrooks.github.io/shopify-theme-lab-docs/
MIT License
740 stars 132 forks source link

Missing 'Add Section' in Homepage for theme user #14

Closed TimSnake13 closed 3 years ago

TimSnake13 commented 3 years ago

Amazing theme as a starting point! Thank you for sharing!

When I was using Debut theme as a base for theme development, its homepage have the options to let the theme user (non-developer) to dynamically add sections (By using "Add Sections" in the theme customize page). But it seems this is theme is missing this option.

I spent a few hours on this problem and still can't figure out why or what's missing.

TimSnake13 commented 3 years ago

Here is a screenshot: https://ibb.co/h7887Qw

sergejcodes commented 3 years ago

Hi there @TimSnake13 ๐Ÿ‘‹๐Ÿป. Good catch, it took me some time to figure this one out. I will release an updated version later.

Here's the fix:

  1. The section file needs a "presets": [...] schema configuration.

Create shopify/sections/my-section.liquid with following content:

<div>
  <div>Some text</div>
</div>

{% schema %}
{
  "name": "My Section",
  "settings": [],
  "presets": [
    {
      "name": "My Section",
      "category": "text"
    }
  ]
}
{% endschema %}
  1. settings_data.json needs a "sections": {...} and "content_for_index": [...] configuration inside current: {...}:

First you might need to run npm run settings:dev, if you adjusted any settings in the Shopify backend, to download the latest settings_data.json

Update shopify/config/settings_data.json to look like this:

{
  "current": {
    "sections": {
      "my-section": {
        "type": "my-section",
        "settings": {}
      }
    },
    "content_for_index": [
      "my-section"
    ]
  },
  "presets": {
    "Default": {}
  }
}

content_for_index tells Shopify which sections are currently selected to display on the index page. But there seems to be a bug on Shopify's part, if you leave this initially empty, the Add sections button is hidden in Shopify's panel.

if you are not running npm run start while editing the files, run npm run deploy:dev to upload the latest files to the remote store

screen-shot

sergejcodes commented 3 years ago

This issue should now be fixed in v2.2.0 release