Last active
September 5, 2017 06:04
-
-
Save ihorduchenko/899dc81471f1b10f1f1c5ca69bb01547 to your computer and use it in GitHub Desktop.
Output list of products types for certain collection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% if collection %} | |
<ul> | |
{% assign typeList = '' %} | |
<!-- if we have a collection, then we don't need to access it through collections... --> | |
{% for product in collection.all_products %} | |
{% capture type %}{{product.type}}{% endcapture %} | |
<!-- using 'unless' instead of 'if () do nothing else do something' --> | |
{% unless typeList contains type %} | |
<li>{{ product.type | link_to_type }}</li> | |
{% capture temp %}{{typeList}}{{product.type}}{% endcapture %} | |
{% assign typeList = temp %} | |
{% endunless %} | |
{% endfor %} | |
</ul> | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment