I have create many collections like All Products, New Releases, T-Shirts, Pants etc. And I have two categories of products like Men's and Women's. Some collections specifically for Men's and some collections specifically for Women's. I create two tags Men's and Women's. I create menu
by collections
query by tags
. My my products collection url
is like this:
/collections/all-products/mens
/collections/all-products/womens
/collections/new-releases/mens
/collections/new-releases/womens
/collections/bras/womens
I want to show some text and menu list when collection.url
show /mens
or /womens
.
{% if collection.url contains mens %}
do something
{% endif %
Above condition not working. I know why not working because {{ collection.url }}
provide /collections/all-products
. {{ page.url }}
will not work for collection object
. I haven't find any suggestion or liquid code reference where show men's or women's products in collections page it will show specific text.
If use in loop
it will work.
{% for product in collection.products %}
{% for tag in product.tags %}
{% if tag contains 'mens' %}
<h3>Mens Products</h3>
{% endif %}
{% endfor %}
{% endfor %}
Above code will not work for me because it's inside loop
. I need to show outside of loop
. I don't understand how to achieve it. here is the reference site. Below have image how I want.
Need help!