shopifyFD
shopifyFD copied to clipboard
[Question] Deep namespace metafields & Liquid
Actually, ShopifyFD allows to create 2 metafields like this:
Namespace | Key |
---|---|
comp.SUB | key |
comp | SUB.key |
Apart from the fact they look alike in the drowdown list box of ShopifyFD, how is this handled in Liquid templating??
What would be the best approach to *build deep namespaces? (don't build it because of XXX is also a good answer)
Thanks, gurus!
That's a weird one.
Never considered adding a period into the namespace or key myself. Never come across someone else doing it either. That makes for some UI fun.
Not sure that I'd add handle that in the newer version but adding a space around the actual separator would do the job. Wonder how many others are also doing this.
Do you often create metafields usually that would result in a double up of comp.sub.key
in the dropdown list?
On a general metafield level (ignoring ShopifyFD), wouldn't the json_string metafield now handle what you're looking for?
From the liquid side - at worst you'll just need to use bracket notation instead.
something.metafields['comp.sub']['sub.key']
Do you often create metafields usually that would result in a double up of comp.sub.key in the dropdown list?
I've just started using ShopifyFD, I haven't built anything like this yet. That's why, I was thinking of this approach using several levels and was wondering whether this could be applied to the key AND to the namespace.
JSON vs deep namespace/key I have seen many people storing JSON data but I am unsure whether this is practical in Liquid, is it?? What would your recommend to handle JSON metafields? E.g.: https://github.com/culturekings/shopify-json-parser
Update Yes, JSON in metafield seems to be quite useful https://github.com/freakdesign/shopifyFD/issues/87 https://help.shopify.com/en/themes/liquid/objects/metafield
Thanks!