February 16, 201610 yr Hi all,Just a quick one here. I am trying to hide tags that contain 'cf-' and '_'.Here is the code that I currently have and it is working fine: {% unless tag contains 'meta-related-collection-' %} {% unless tag contains 'cf-' %} {% unless tag contains '_' %} content {% endunless %} {% endunless %} {% endunless %} I was trying to write it like this: {% unless tag contains 'meta-related-collection-' or 'cf-' or '_' %} content {% endunless %} But that removes all Tags.Is there a better way to write this code?Thanks,Al.
February 16, 201610 yr You may need to do something like this. {% if tag contains 'meta-related-collection-' or tag contains 'cf-' or tag contains '_' %} {% endif %} You will need to ask Shopify directly, but basically it would be nicer to pass in an array instead. {% assign supportedTags = ['meta-related-collection-', '-', 'cf-'] %} {% if tag in supportedTags %} content {% endif %} This code won't work, it's a mixture of a similar language called Twig, and Shopify's Liquid, but it should give you an indication to at least go back to Shopify with. Edited February 16, 201610 yr by Jack
February 16, 201610 yr Author Hey Jack, thanks for the reply. I had posted the above in the Shopify Forums but the post disappeared, my posts are not displayed for some reason there and sometimes I get locked out of the Forums, been onto Shopify support a few times about it but I don't think they really have an answer why. Anyway, I have updated the code to this: {% unless tag contains 'meta-related-collection-' or tag contains 'cf-' or tag contains '_' %} content {% endunless %} And that has also worked! Thanks again mate =)
February 16, 201610 yr Hey Jack, thanks for the reply. I had posted the above in the Shopify Forums but the post disappeared, my posts are not displayed for some reason there and sometimes I get locked out of the Forums, been onto Shopify support a few times about it but I don't think they really have an answer why. Anyway, I have updated the code to this: {% unless tag contains 'meta-related-collection-' or tag contains 'cf-' or tag contains '_' %} content {% endunless %} And that has also worked! Thanks again mate =) The array method would be my preferred way. If you ever need to add to that list of selectors then it will start to become messy. You can always bother Shopify on Twitter, if you have an account. Glad it's working anyway. It's impossible to test because I don't have an account.
Create an account or sign in to comment