How can I create a dynamic custom section for various content types?

Hi, I have been trying to create a custom section to select between HTML, text, videos, and images along with custom width and making it dynamic. I am unable to do it. Can you please help? I was able to do it for texts.


    

      {% case section.blocks.size %}
        {% when 0 %}
        {% when 1 %}
          {% assign column_width = 'text-center' %}
        {% when 2 %}
          {% assign column_width = 'post-large--one-half medium--one-half' %}
        {% when 3 %}
          {% assign column_width = 'post-large--one-third medium--one-third' %}
        {% when 4 %}
          {% assign column_width = 'post-large--one-quarter medium--one-half' %}
        {% when 5 %}
          {% assign column_width = 'post-large--one-fifth medium--one-half' %}
        {% when 6 %}
          {% assign column_width = 'post-large--one-sixth medium--one-half' %}
      {% endcase %}

      {% for block in section.blocks %}
        {% case block.type %}

        {% when 'text' %}
            

              ### {{ block.settings.title }}
              {{ block.settings.richtext }}

            

{% endcase %}
      {% endfor %}
  

  

{% schema %}
  {
    "name": "Test Custom",
    "max_blocks": 6,
    "blocks": [
      {
        "type": "text",
        "name": "Text",
        "settings": [
          {
            "type": "text",
            "id": "title",
            "label": "Text",
          },
          {
            "type": "richtext",
            "id": "richtext",
            "label": "Text"
          }
        ]
      }
{% endschema %}
1 Like

@lilac

sorry for any issue

you can try this way

http://www.codeshopify.com/blog_posts/shopify-sections-with-dynamic-blocks

1 Like