Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Deep namespace metafields & Liquid #90

Open
guillaumegarcia13 opened this issue Nov 15, 2018 · 2 comments
Open

[Question] Deep namespace metafields & Liquid #90

guillaumegarcia13 opened this issue Nov 15, 2018 · 2 comments

Comments

@guillaumegarcia13
Copy link

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!

@freakdesign
Copy link
Owner

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']

@guillaumegarcia13
Copy link
Author

guillaumegarcia13 commented Nov 16, 2018

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
#87
https://help.shopify.com/en/themes/liquid/objects/metafield

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants