Wanting to check whether a block type has been created in a section

EllouiseHNuebar
Visitor
3 0 2

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:

 

<div id="tabs">
<ul>
<li><a href="#A">A</a></li>
<li><a href="#B">B</a></li>
<li><a href="#C">C</a></li>
</ul>

<div id="A">
{% for block in section.blocks %}
    {% if block.type == 'A' %}
    {% include 'ingredientItem' %}
    {% endif %}
    {% endfor %}
</div>
<div id="B">
{% for block in section.blocks %}
    {% if block.type == 'A' %}
    {% include 'ingredientItem' %}
    {% endif %}
    {% endfor %}
</div>
<div id="C">
{% for block in section.blocks %}
    {% if block.type == 'A' %}
    {% include 'ingredientItem' %}
    {% endif %}
    {% endfor %}
</div>
</div>

 

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:

<div id="tabs">
<ul>
<li>{% if block.type == A%}<a href="#A">A</a>{% else %}<span class="inactive">A</span>{% endif %}</li>
</ul>

<div id="A">
{% for block in section.blocks %}
    {% if block.type == 'A' %}
    {% include 'ingredientItem' %}
    {% endif %}
    {% endfor %}
</div>

</div>

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.

Reply 1 (1)

KetanKumar
Shopify Partner
36845 3636 11978

@EllouiseHNuebar 

sorry for this issue can you please try maybe helpful this

http://www.codeshopify.com/blog_posts/shopify-sections-with-dynamic-blocks

If helpful then please Like and Accept Solution.
Want to modify or custom changes on store Hire me.
- Feel free to contact me on bamaniyaketan.sky@gmail.com regarding any help
Shopify Partner | Skype : bamaniya.sky
PSD to Shopify | Shopify Design Changes | Shopify Custom Theme Development and Desing | Custom Modifications In to Shopify Theme | SEO & Digital Marketing