Hello all
I am setting up an online record shop and on each product page I would like to display a collection that represents the record label for that product (and I would like it to display as a link to that label collection).
Each product has at least 3 collections assigned (an artist collection, a genre collection, a label collection). Eg for a product by an artist called Aphex Twin:
artist collection name: âAphex Twinâ
genre collection name: âTechno/IDMâ
label collection name: âWarp Recordsâ
Unfortunately I have no coding experience. How can i use custom Liquid to display specifically the label collection on the product page? (Is there a way to tag collections somehow so that it can look for âlabelâ type collections?)
I have tried the below but this does not work as the product collection arrays are ordered alphabetically so will just show whichever of the productâs artist/genre/label collections come last alphabetically:
{% assign product_collection = product.collections.last %}
{% if product_collection %}
{{ product_collection.title | link_to: product_collection.url }}
{% endif %}
I also tried prefixing the names of all label collections with the word âlabelâ eg collection name is âLabel: Warp Recordsâ and then using some code to search for any collection for that product with the word âLabelâ in eg:
{% for collection in product.collections %}
{{collection.title | where: 'Label' }}
{% endfor %}
(Although havenât figured out how to turn that into a link - and I would rather avoid using a prefix like this if possible).
Just wondering if anybody could provide some guidance/advice/instructions on how best to do this.
Many thanks in advance for your help!
Justin / Spectrum City
PS site is not live yet