This repository has been archived by the owner on Aug 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 473
/
collection-sidebar.liquid
executable file
·66 lines (56 loc) · 2.11 KB
/
collection-sidebar.liquid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!-- /snippets/collection-sidebar.liquid -->
{% comment %}
Side navigation for the product types, vendors, and tags.
These can be based on the current collection or all products. Details in comments below.
Note: Clicking on a tag will filter the products within the current collection.
Clicking on a type or vendor link will take you out of the current collection
to a standalone collection page. E.g. /collections/vendors?q=Pepsi
{% endcomment %}
{% comment %}
Product tags in the current collection
{% endcomment %}
{% if collection.all_tags.size > 0 %}
<h3>{{ 'collections.sidebar.tags' | t }}</h3>
{% comment %}
To provide a 'catch-all' link at the top of the list,
check against the collection.handle, product type, and vendor.
{% endcomment %}
<ul class="no-bullets">
<li{% unless current_tags %} class="filter--active"{% endunless %}>
{% comment %}
Good for /collections/all collection and regular collections
{% endcomment %}
{% if collection.handle %}
<a href="/collections/{{ collection.handle }}">All {{ collection.title }}</a>
{% comment %}
Good for automatic type collections
{% endcomment %}
{% elsif collection.current_type %}
<a href="{{ collection.current_type | url_for_type }}">All {{ collection.title }}</a>
{% comment %}
Good for automatic vendor collections
{% endcomment %}
{% elsif collection.current_vendor %}
<a href="{{ collection.current_vendor | url_for_vendor }}">All {{ collection.title }}</a>
{% endif %}
</li>
{% comment %}
And for the good stuff, loop through the tags themselves.
{% endcomment %}
{% for tag in collection.all_tags %}
{% if current_tags contains tag %}
<li class="filter--active">
{{ tag | link_to_remove_tag: tag }}
</li>
{% else %}
<li>
{% comment %}
Use link_to_add_tag if you want to allow filtering
by multiple tags
{% endcomment %}
{{ tag | link_to_tag: tag }}
</li>
{% endif %}
{% endfor %}
</ul>
{% endif %}