I want to display a slider/carousel above the header navigation. The code can be edited inside header.liquid. The contents of the slider are configured via {% schema %}{% endschema %}
header.liquid
{% for i in (1..3) %}
{% assign announcement_text = "announcement_text_" | append: forloop.index %}
{{ section.settings.[announcement_text] }}
{% endfor %}
{% schema %}
{
"name": "Header",
"settings": [
{
"type": "richtext",
"id": "announcement_text_1",
"label": "Text 1",
"default": "
Announcement 1
"
},
{
"type": "richtext",
"id": "announcement_text_2",
"label": "Text 2",
"default": "
Announcement 2
"
},
{
"type": "url",
"id": "announcement_url_1",
"label": "Announcement Link 1"
},
{
"type": "url",
"id": "announcement_url_2",
"label": "Announcement Link 2"
},
],
"blocks": [
{
"type": "sub_menu",
"name": "sub_menu",
"settings": [
....
]
}
]
}
{% endschema %}
As you can see on the Schema and code above, I am trying to loop through the announcement_text_1 and announcement_text_2 id’s via the announcement_text variable since it has an incrementing index.
Problem: I am prompted with Liquid syntax error (line 60): Expected id but found open_square in "{{ section.settings.[announcement_text] in my terminal.
Do you know what should be the correct syntax for section.settings.[announcement_text]?
Any help is greatly appreciated. Thank you.