Hello Cherb, I came across this post as i am seeking help with a very similar concern and managed to read your fantastic response. It really seems you know your way around a theme’s coding editor. I would be grateful if you could point me in the right direction regarding a similar enquiry . My goal is to add a custom section on my product pages with customaziable content. I believe that i already have the accurate code that would make that feasible. (ATTACHED BELOW) . Although i HAVE NO IDEA WHERE exactly in the code editor i must PASTE the piece of code for my custom section to work as intended. I also DO NOT KNOW whether i should duplicate the original code in order to add custom changes. OR Whether i can directly add them to the original .
{
"name": "Custom Section",
"settings": [
{
"type": "text",
"id": "heading",
"label": "Heading Text",
"default": "Why we are better"
},
{
"type": "select",
"id": "heading_font",
"label": "Heading Font",
"options": [
{ "value": "default", "label": "Default" },
{ "value": "custom", "label": "Custom" }
]
},
{
"type": "font_picker",
"id": "custom_heading_font",
"label": "Custom Heading Font",
"default": "Arial"
},
{
"type": "range",
"id": "heading_font_size",
"label": "Heading Font Size",
"default": 24,
"min": 16,
"max": 48,
"unit": "px"
},
{
"type": "range",
"id": "icon_size",
"label": "Icon Size",
"default": 24,
"min": 16,
"max": 48,
"unit": "px"
},
{
"type": "image_picker",
"id": "main_image",
"label": "Main Image"
},
{
"type": "select",
"id": "image_position",
"label": "Image Position",
"options": [
{ "value": "left", "label": "Left" },
{ "value": "right", "label": "Right" },
{ "value": "center", "label": "Center" }
]
},
{
"type": "range",
"id": "image_border_radius",
"label": "Image Border Radius",
"default": 0,
"min": 0,
"max": 50,
"unit": "%"
},
{
"type": "checkbox",
"id": "enable_lazy_load",
"label": "Enable Lazy Load",
"default": true
},
{
"type": "color",
"id": "section_background_color",
"label": "Section Background Color",
"default": "#ffffff"
}
],
"blocks": [
{
"type": "text",
"name": "Text",
"settings": [
{
"type": "textarea",
"id": "text_content",
"label": "Text Content"
}
]
},
{
"type": "image",
"name": "Image",
"settings": [
{
"type": "image_picker",
"id": "block_image",
"label": "Block Image"
}
]
},
{
"type": "icon",
"name": "Icon",
"settings": [
{
"type": "image_picker",
"id": "block_icon",
"label": "Block Icon"
},
{
"type": "text",
"id": "icon_text",
"label": "Icon Text"
}
]
}
],
"presets": [
{
"name": "Default",
"category": "Custom Sections"
}
]
}
Liquid Template:
{% schema %}
{
"name": "Custom Section",
"settings": [
{
"type": "text",
"id": "heading",
"label": "Heading Text",
"default": "Why we are better"
},
{
"type": "select",
"id": "heading_font",
"label": "Heading Font",
"options": [
{ "value": "default", "label": "Default" },
{ "value": "custom", "label": "Custom" }
]
},
{
"type": "font_picker",
"id": "custom_heading_font",
"label": "Custom Heading Font",
"default": "Arial"
},
{
"type": "range",
"id": "heading_font_size",
"label": "Heading Font Size",
"default": 24,
"min": 16,
"max": 48,
"unit": "px"
},
{
"type": "range",
"id": "icon_size",
"label": "Icon Size",
"default": 24,
"min": 16,
"max": 48,
"unit": "px"
},
{
"type": "image_picker",
"id": "main_image",
"label": "Main Image"
},
{
"type": "select",
"id": "image_position",
"label": "Image Position",
"options": [
{ "value": "left", "label": "Left" },
{ "value": "right", "label": "Right" },
{ "value": "center", "label": "Center" }
]
},
{
"type": "range",
"id": "image_border_radius",
"label": "Image Border Radius",
"default": 0,
"min": 0,
"max": 50,
"unit": "%"
},
{
"type": "checkbox",
"id": "enable_lazy_load",
"label": "Enable Lazy Load",
"default": true
},
{
"type": "color",
"id": "section_background_color",
"label": "Section Background Color",
"default": "#ffffff"
}
],
"blocks": [
{
"type": "text",
"name": "Text",
"settings": [
{
"type": "textarea",
"id": "text_content",
"label": "Text Content"
}
]
},
{
"type": "image",
"name": "Image",
"settings": [
{
"type": "image_picker",
"id": "block_image",
"label": "Block Image"
}
]
},
{
"type": "icon",
"name": "Icon",
"settings": [
{
"type": "image_picker",
"id": "block_icon",
"label": "Block Icon"
},
{
"type": "text",
"id": "icon_text",
"label": "Icon Text"
}
]
}
],
"presets": [
{
"name": "Default",
"category": "Custom Sections"
}
]
}
{% endschema %}
{% style %}
.custom-section {
background-color: {{ section.settings.section_background_color }};
text-align: center;
padding: 20px;
}
.custom-section .heading {
font-size: {{ section.settings.heading_font_size }}px;
{% if section.settings.heading_font == 'custom' %}
font-family: {{ section.settings.custom_heading_font.family }};
{% endif %}
}
.custom-section .icon {
width: {{ section.settings.icon_size }}px;
height: {{ section.settings.icon_size }}px;
}
.custom-section .image {
{% if section.settings.image_position == 'left' %}
float: left;
{% elsif section.settings.image_position == 'right' %}
float: right;
{% else %}
margin: 0 auto;
{% endif %}
border-radius: {{ section.settings.image_border_radius }}%;
{% if section.settings.enable_lazy_load %}
loading: lazy;
{% endif %}
}
{% endstyle %}
<div class="custom-section">
<h2 class="heading">{{ section.settings.heading }}</h2>
<div class="main-image">
<img src="{{ section.settings.main_image | image_url }}" class="image" alt="Main Image">
</div>
{% for block in section.blocks %}
{% case block.type %}
{% when 'text' %}
<div class="text-content">
{{ block.settings.text_content }}
</div>
{% when 'image' %}
<div class="block-image">
<img src="{{ block.settings.block_image | image_url }}" class="image" alt="Block Image">
</div>
{% when 'icon' %}
<div class="block-icon">
<img src="{{ block.settings.block_icon | image_url }}" class="icon" alt="Block Icon">
<p>{{ block.settings.icon_text }}</p>
</div>
{% endcase %}
{% endfor %}
</div>
I would immensely appreciate any guidance you can provide me in solving this.