Filter generated UL's that don't have LI's in them

Filter generated UL's that don't have LI's in them

JHMProject
Visitor
2 0 0

Hello,  I need some help. 

I have made a For loop that goes through Metaobjects and lists them.  I have it set up to create a UL for each letter of the alphabet.  However, I cannot figure out how to hide the letters that don't have anything under them.  Basically a UL with no LIs in them.  If anyone has an Idea Please help!

 

Here is the code:

 

 

 

{% assign alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | split: "" %}
{% for letter in alphabet %} 
      <div class="section_header">{{ letter }}</div>
            <div class="product_grid">
            <ul class="products">
  {% for publication in shop.metaobjects.publication_catalog.values %}
      {% for reference in publication.title %}
        {% assign refer = reference | remove: "The " | slice: 0 %}
          {% if refer == letter %}
                  <li id="product">
                  <div class="container">
                    {% if publication.format == false %}
                        <a href="{{ publication.series_url }}"><img src="{{ publication.series | image_url: width: 200, height: 300}}"></a>
                    {% elsif publication.format == true %}
                      <a href="{{ publication.single_url }}"><img src="{{ publication.single |  image_url: width: 200, height: 300}}"></a>                   
                    {% else %}
                        {% break %}
                    {% endif %}
                  </div>
                </li>
                {% else %}
                  {% break %}
                {% endif %}
        
        {% endfor %} 
  {% endfor %} 
        </ul>  
        </div>
{% endfor %}

 

 

 

 

 

 

Any help would be appreciated.

Replies 0 (0)