We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Hide a video section if no META data is entered

Hide a video section if no META data is entered

Steve_Klein
Shopify Partner
9 0 0

I am looking to hide a video section on a collection page in the Dawn theme that is driven by META data. How do I accomplish this?

Replies 2 (2)

FePixie
Shopify Partner
30 2 7

maybe with a liquid bit like...

{%- if product.metafields.custom.fieldID == blank -%}
// add some javascript to hunt and hide the element
{%- endif -%}

 

or like this to output the vid in the first place only if it has one

{%- if product.metafields.custom.fieldID != blank -%}

  // add the video element html + liquid url

{%- endif -%}

Steve_Klein
Shopify Partner
9 0 0

I tried to wrap this code in the JSON file but it did not let me save…

"feacf191-d7b3-438d-bc89-4aab226dc7df": {
"type": "video",
"settings": {
"heading": "Artist Video if applicable",
"heading_size": "h2",
"enable_video_looping": false,
"video": "{{ collection.metafields.custom.artist_video_if_applicable_.value }}",
"video_url": "",
"description": "",
"full_width": false,
"color_scheme": "accent-1",
"padding_top": 36,
"padding_bottom": 36
}
}
},