Created
February 6, 2014 20:09
-
-
Save kyleaparker/8851659 to your computer and use it in GitHub Desktop.
Shopify: Map all collection tags (avoid 50 product limit)
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
{% assign collection_tags = collection | map: 'tags' %} | |
{% for tag in collection_tags %} | |
<a href="/collections/{% if collection.handle != blank %}{{ collection.handle }}{% else %}all{% endif %}/{{ tag | handleize }}" title="{{ tag | escape }}">{{ tag }}</a> | |
{% endfor %} |
@darryn sorry just saw this!
Yup you can create an array of product titles. You would use something like:
{% assign all_products = collections.all.products | map: 'title' %}
{% for title in all_products %}
{{ title }}
{% endfor %}
I looks like it doesn't work with tags, possibly because collection.tags is already an array? Like this:
{% for tag in collection.tags %}
{{ forloop.index }}
{% endfor %}
However, your example would work like this:
{% assign collection_titles = collections.all.products | map: 'title' %}
{% for title in collection_titles %}
{{ forloop.index }} {{ title }}
{% endfor %}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@kyleaparker can you use the map filter to create an array of all the product titles in a collection? E.g. something like:
Also, I noticed that the map filter seems to output a single string of values. If I add a forloop index to your tags/map snippet it only gives me one iteration.
http://monosnap.com/image/t6mPYjgP8M7Y4hyADBH3sWQl7JbLkZ
Is this right? What be's going ons yo?