Created
July 13, 2018 15:00
-
-
Save estrattonbailey/934ba36fe0e67129afb9227c536537ea to your computer and use it in GitHub Desktop.
Sort shopify collection by last names
This file contains hidden or 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
<div class='collection-list no-pad rel'> | |
<div class='outer'> | |
<div class='container'> | |
{% assign lnames = '' %} | |
{% assign letters = '' %} | |
{% for collection in collections %} | |
{% if collection.title contains 'Designer:' %} | |
{% assign name = collection.title | split: ':' | last %} | |
{% assign rname = name | split: "" | reverse | join: "" %} | |
{% assign lrname = rname | split: " " | first %} | |
{% assign lname = lrname | split: "" | reverse | join: "" %} | |
{% if lnames == '' %} | |
{% assign lnames = lnames | append: lname | append: ':' | append: collection.handle %} | |
{% else %} | |
{% assign lnames = lnames | append: ',' | append: lname | append: ':' | append: collection.handle %} | |
{% endif %} | |
{% assign letter = lname | split: '' | first %} | |
{% if letters == '' %} | |
{% assign letters = letters | append: letter %} | |
{% else %} | |
{% assign letters = letters | append: ',' | append: letter %} | |
{% endif %} | |
{% endif %} | |
{% endfor %} | |
{% assign letters = letters | split: ',' | sort | uniq %} | |
{% assign alpha = lnames | split: ',' | sort %} | |
{% for letter in letters %} | |
<h2 id='{{ letter }}' class='mb05 mt1 medium'>{{letter}}</h2> | |
<div class='collection-list__cards f ais fw'> | |
{% for value in alpha %} | |
{% assign lname = value | split: ':' | first %} | |
{% assign firstletter = lname | split: '' | first %} | |
{% assign handle = value | split: ':' | last %} | |
{% if firstletter == letter %} | |
<div class='collection-list__card collection-list__card--designer'> | |
{% include 'collection-card' with collection: collections[handle] %} | |
</div> | |
{% endif %} | |
{% endfor %} | |
</div> | |
{% endfor %} | |
</div> | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment