if template is product or any product based template

Beezer
Shopify Partner
43 0 0

For my meta descriptions i am using {% when 'product' %} to identify the product template. But I have other versions of this template, say {% when 'product.fuji' %} and so I have to add a new line in the liquid to accommodate each template.

I was wondering if there is a way to write the liquid to reference all "product" based templates?

like {% when 'product.*' %} for example.

0 Likes
tetchi
Shopify Staff (Retired)
Shopify Staff (Retired)
489 0 45

Hey Beezer!

You could do {% if template == "product" %} 

www.tetchi.ca | www.twitter.com/t3tchi
tetchi
Shopify Staff (Retired)
Shopify Staff (Retired)
489 0 45

or if you have alternate product templates, you should be able to do:

{% if template contains 'product' %}

www.tetchi.ca | www.twitter.com/t3tchi

Does not seem to work if we place this code in a "styles.css.liquid" file. Any idea why ?

C'est simple comme bonjour ! Ou presque.
0 Likes
LetsGetDigital
Shopify Partner
11 0 23

That is liquid code, not css. It needs to be used in a construction file, like theme.liquid

0 Likes
AvidBrio
Shopify Expert
199 9 17

@Beezer  

you can check the template or handler like below example 

 

 

<div class="{% if template contains 'product' %}grid__item {{ grid_item_width }}   {% else%}list-view-item  {% endif%} ">
        {% if template contains 'product' %}        	
        	{% include 'product-card-grid', max_height: max_height %}
        {% else%}
        	{% include 'product-card-list', max_height: max_height %}
        {% endif%}

 

If you find our comment helpful, hit the like button and accept it as a solution.
Want us to implement custom changes in your store? Contact us
Email me directly - jim@avidbrio.com
0 Likes