Personalized checkout and custom promotions with Shopify Scripts
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.
2m ago Learn the essential skills to navigate the Shopify admin with confidence. T...
By Shopify Feb 12, 2025Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025