Skip to content

Instantly share code, notes, and snippets.

@joe-dempsey
Last active June 22, 2016 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joe-dempsey/3ec1efca15d8075ba39ab2011f944850 to your computer and use it in GitHub Desktop.
Save joe-dempsey/3ec1efca15d8075ba39ab2011f944850 to your computer and use it in GitHub Desktop.
{% comment %}let's build a list of collections based on a menu of collections.{% endcomment %}
{% comment %}this can be added to a page or collection - I'm assuming collection.{% endcomment %}
{% comment %}to start you need a menu which contains a list of links to collections.{% endcomment %}
{% comment %}this is a barebones version - which is supposed to be pulled into a theme so edit grid/loop etc as required{% endcomment %}
{% comment %}for custom shopify theme development email design at liquid dot gallery {% endcomment %}
{% comment %} our menu of collections has the handle "in-wild" {% endcomment %}
{% assign mastercollection = collection %} {% comment %}don't need this if using a page - use it to escape the for loop and reassign original collection.{% endcomment %}
{% for link in linklists['in-wild'].links %} <!-- #for1 --> {% comment %}for every link in the menu {% endcomment %}
{% if link.type == 'collection_link' %} <!-- #if1 --> {% comment %}If we have a collection link.{% endcomment %}
{% assign collection = link.object %} {% comment %}assign the collection.{% endcomment %}
<h1>{{ collection.title }}</h1>
{% if collection.description != '' %} {% comment %}get collection title and desc.{% endcomment %}
{{ collection.description }}
{% endif %}
<div class="products-grid"> {% comment %}product item loop - get from your theme collection file.{% endcomment %}
<div class="row">
{% if collection.products.size > 0 %}
{% for product in collection.products %}
{% include 'product-grid-item-category' %}
{% endfor %}
{% else %}
<p style="text-align: center;">There are no products in this collection.</p>
{% endif %}
</div>
</div>
{% endif %}<!-- /#if1 -->
{% endfor %}<!-- /#for1 -->
{% assign collection = mastercollection %} {% comment %}reassign the main collection if used on collection page.{% endcomment %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment