Showing a metafield on a collection page based on collection

Solved
abe2
Tourist
6 0 1

Hi - I am trying to add some text to a collection page, based on what collection the product is in.

We sell coffee, so if a visitor visits the coffee collection it should show the taste notes on the collection page. If the visitor goes to the equipment collection nothing should show.

I can add the taste notes field in, it just shows on every collection ;(

Thanks

0 Likes
suyash1
Shopify Partner
3260 364 533

@abe2 - it is because shopify shares same template files for all collections. 

To have different description, you will need to have different templates for different collections.  If there are too many collections, then it is not feasible.

You are welcome to contact me, my email - suyash.patankar@gmail.com
Free Shopify solutions/tutorials on youtube
#1 page builder app on Shopify - for FREE! PageFly
0 Likes
abe2
Tourist
6 0 1

Hi, yes, it shared the same collection page. We only have 3 collections in total. Coffee, Coffee Subscriptions and Equipment. 

0 Likes
suyash1
Shopify Partner
3260 364 533

@abe2 - then you need 3 collection templates... each for one category and you can set description for it

You are welcome to contact me, my email - suyash.patankar@gmail.com
Free Shopify solutions/tutorials on youtube
#1 page builder app on Shopify - for FREE! PageFly
0 Likes
abe2
Tourist
6 0 1

Thank you. Just to be clear - everything about the collection pages is fine - I just want to show one text line under above the price. 
do I really need to create new collection templates to do that?

0 Likes
Kyle_W
Shopify Expert
144 25 86

This is an accepted solution.

I just want to show one text line under above the price. do I really need to create new collection templates to do that?

@abe2 If there's only a slight difference between the collection pages, then you don't really need to create separate collection templates. Instead, you could use some Liquid control flow tags to show different content based on the collection. For example: 

{% if collection.handle == 'coffee' %}
  do something
{% endif %}

Docs for reference:

Hopefully this helps!

 

Kyle W | Helium Dev, LLC
Helium builds apps for Shopify that thousands of merchants depend on:
- Customer Fields
- Meteor Mega Menu
abe2
Tourist
6 0 1

That’s the one. Thank you! I don’t suppose you have a reference for building different collection page templates?

 

0 Likes
Kyle_W
Shopify Expert
144 25 86

You're most welcome, @abe2!

Here's a link to Shopify's docs for theme templates: https://shopify.dev/themes/architecture/templates 

Kyle W | Helium Dev, LLC
Helium builds apps for Shopify that thousands of merchants depend on:
- Customer Fields
- Meteor Mega Menu