How to show or hide content from a block inside a section in liquid

Topic summary

Issue: A developer wants to conditionally show/hide content from a block within a Shopify Liquid section based on whether a metafield (specifically an image/icon) is empty.

Current Status:

  • Successfully hiding/showing section-level content using {%- if section.settings.maintooltip_product != blank -%}
  • Unable to apply the same logic to block-level content using blocks.settings.content_tooltip

Code Context:

  • Working with a “Tools Tips” section that can contain up to 3 blocks
  • Each block has settings including content_tooltip (rich text) and tooltip_icon (image picker)
  • Schema includes color customization options and localization support

Solution Provided:
To access block settings, you must loop through the blocks rather than referencing them directly:

{%- for block in section.blocks -%}
  {%- if block.settings.content_tooltip != blank -%}
    <!-- content here -->
  {%- endif -%}
{%- endfor -%}

Key Point: Block settings require iteration through section.blocks, unlike section settings which can be accessed directly via section.settings.

Summarized with AI on November 11. AI used: claude-sonnet-4-5-20250929.

Hello there,

I want to be able to hide/or show an object, depending on “if” the meta field is empty or not, of an image/icon, on the schema structure it is a “block” coming from a “section”.

So if the block content is not filled, is not shown.

I’m able to hide and show content if the checkbox from the section by using

{%- if section.settings.maintooltip_product != blank -%}

But when I try the same for a block, for example

.content_tooltip

seems not been working

Any help is much appreciated

Structure on store front:

{% stylesheet %}
{% endstylesheet %}

{% javascript %}
{% endjavascript %}

{%- if blocks.settings.content_tooltip != blank -%}  
  
  <div class="flex-tooltip_main">
  <p> Hello </p>
  </div>

{%- endif -%}

{% schema %}
{
  "name": "Tools Tips",
  "tag": "section",
  "class": "slideshow",
  "limit": 1,
  "settings": [
    {
            "type": "checkbox",
            "id": "maintooltip_product",
            "default": true,
            "label": "Show Tool Tips",
            "info": "The tools tips, are soft insights about the current product displayed, there is a maximum of 3 insights per product."
          },
    {
      "type": "text",
      "id": "title",
      "label": "Tool Tips"
    },
    {
          "type": "color",
          "id": "icon_bg_color",
          "label": "Icons Background",
          "default":"#ffffff"
          },
          {
          "type": "color",
          "id": "tooltip_bg_color",
          "label": "Tool Tips Background",
          "default":"#ffffff"
          },
          {
          "type": "color",
          "id": "Text_tooltip_color",
          "label": "Tool Tips Text",
          "default":"#ffffff"
          }
          
  ],
  "max_blocks": 3,
  "blocks": [
     {
       "name": "Tool",
       "type": "slide",
       "settings": [
         
          {
          "type": "richtext",
          "id": "content_tooltip",
          "label": "Content One (1)"
          },
         {
          "type": "image_picker",
          "id": "tooltip_icon",
          "label": "Icon ToolTip",
          "info": "Recommended .svg format"
          }
       ]
     }
  ],
  "presets": [
    {
      "name": "Tools Tips",
      "settings": {
        "title": "Tool Tips"
      },
      "blocks": [
        {
          "type": "slide"
        },
        {
          "type": "slide"
        }
      ]
    }
  ],
  "locales": {
    "en": {
      "title": "Tool Tips"
    },
    "fr": {
      "title": "Tool Tips"
    }
  },
  "enabled_on": {
    "templates": ["*"],
    "groups": ["footer"],
    "groups": ["aside"]
  }
}
{% endschema %}

Thank you!

Hi

To access the blocks you will need to loop through them.

{%- for block in section.blocks -%}

{%- endfor -%}

This is not the case for

section.settings