Hi everyone, especially perfectionists!
I am trying to create a multi-announcement bar with links similar to this one: https://www.beardbrand.com
Does anyone have an idea how to achieve this?
I’ve tried a code mentioned by a Shopify Community Member, but it doesn’t seem to work:
{%- if section.settings.enable_bar -%}
{%- unless section.settings.home_page_only and template != 'index' -%}
{%- endunless -%}
{%- endif -%}
{% schema %}
{
"name": "Announcement bar",
"settings": [
{
"type": "checkbox",
"id": "enable_bar",
"label": "Enable bar",
"default": true
},
{
"type": "checkbox",
"id": "home_page_only",
"label": "Home page only",
"default": false
},
{
"type": "color",
"id": "background",
"label": "Background",
"default": "#000000"
},
{
"type": "color",
"id": "text_color",
"label": "Text",
"default": "#ffffff"
}
],
"blocks": [
{
"type": "announcement_bar",
"name": "Announcement Bar",
"settings": [
{
"id": "content",
"type": "text",
"label": "Announce something here"
},
{
"id": "link",
"type": "url",
"label": "Link"
}
]
}
],
"presets":[
{
"name":"Announcement bar"
}
]
}
{% endschema %}
I took the entire code and replaced the current announcement bar code, but it seems to not be working.
Original code:
{%- if section.settings.enable_bar -%}
{%- unless section.settings.home_page_only and template != 'index' -%}
{%- endunless -%}
{%- endif -%}
{% schema %}
{
"name": "Announcement bar",
"settings": [
{
"type": "checkbox",
"id": "enable_bar",
"label": "Enable bar",
"default": true
},
{
"type": "checkbox",
"id": "home_page_only",
"label": "Home page only",
"default": false
},
{
"type": "color",
"id": "background",
"label": "Background",
"default": "#000000"
},
{
"type": "color",
"id": "text_color",
"label": "Text",
"default": "#ffffff"
},
{
"type": "text",
"id": "content",
"label": "Text",
"default": "Announce something here"
},
{
"type": "url",
"id": "link",
"label": "Link"
}
]
}
{% endschema %}