Using liquid filter to display metaobject fields using custom liquid block in theme editor.

Solved

Using liquid filter to display metaobject fields using custom liquid block in theme editor.

MattH1
Tourist
4 1 2

I'm trying to reference information from a metaobject in the custom liquid block for different templates. For instance, I have a metaobject with fields of data that I want to display on a collections page. I know I can use the "connect to dynamic source" option on blocks. But I want to use {{ }} syntax to reference a field in a custom liquid block, as I'm trying to do something specific. The documentation here shows thatI should used the following syntax:

 

{{ shop.metaobjects.testimonials.homepage.title }}
{{ shop.metaobjects['highlights']['washable'].image.value }}

So my syntax comes out to:

 

 

<p>{{ shop.metaobjects.mtn_info.beaver_creek.mountain.value }}</p>

 

 

But this returns nothing. In fact, I can't get the custom liquid to display any info at all from my metaobject.

 

I have confirmed and triple checked the type and key names. The only thing I'm not 100% sure about is what the handle is. Is this the same as entry name? I can't find anywhere where it specifically states what the handle is. 

 

Can anyone help please?

Accepted Solution (1)

MattH1
Tourist
4 1 2

This is an accepted solution.

Ok the next resource I checked explained that handles use hyphens "-" for spaces so my tag should have been:

 

<p>{{ shop.metaobjects.mtn_info.beaver-creek.mountain.value }}</p>

 

 I'm leaving this here since I couldn't find that info stated clearly in the metaobject documentation, and hopefully this helps others.

View solution in original post

Reply 1 (1)

MattH1
Tourist
4 1 2

This is an accepted solution.

Ok the next resource I checked explained that handles use hyphens "-" for spaces so my tag should have been:

 

<p>{{ shop.metaobjects.mtn_info.beaver-creek.mountain.value }}</p>

 

 I'm leaving this here since I couldn't find that info stated clearly in the metaobject documentation, and hopefully this helps others.