Hello,
I’m building an ingredients page that has the alphabet at the top as tabs and the content for each letter underneath.
I’ve set up block types to manage this, ie:
- A
- B
- C
{% for block in section.blocks %}
{% if block.type == 'A' %}
{% include 'ingredientItem' %}
{% endif %}
{% endfor %}
{% for block in section.blocks %}
{% if block.type == 'A' %}
{% include 'ingredientItem' %}
{% endif %}
{% endfor %}
{% for block in section.blocks %}
{% if block.type == 'A' %}
{% include 'ingredientItem' %}
{% endif %}
{% endfor %}
What I would like to do is to check if there has been a block type created and only apply my link to the letter in the list if that block type exists.
eg:
- {% if block.type == A%}A{% else %}A{% endif %}
{% for block in section.blocks %}
{% if block.type == 'A' %}
{% include 'ingredientItem' %}
{% endif %}
{% endfor %}
But obviously, what I have here doesn’t work. I was looking for some help as to how to check for a block type’s existence.
Thanks for any help you can provide.