Issues developing a custom section setting with type metaobject_list and metaobject_type

Issues developing a custom section setting with type metaobject_list and metaobject_type

masebase
Excursionist
12 3 8

I am customizing my theme and taking advantage of the new Metaobject definitions. 

 

I've created a Metaobject for a landing page template. I will create different landing page data entries for different landing pages that I want. Then I'm creating a Template for the Landing page metaobject. My metaobject has things like H1 Title, Button label, Button link, featured collection, marketing copy, etc. 

 

One of the sections I want to include is FAQs, but not all of the same FAQs will appear on each landing page. So I've created a field referencing another Metaobject called "FAQs" (handle is `faqs`). This way I can select any number of relevant FAQs in each Landing Page data entries in my custom Metaobject. 

 

Now when developing a Section in my page to show these FAQs, I wanted to have a setting, that would allow me to bind the contents of the section to the Landing Page metaobject that has my selected FAQs. So I believe I want to have a setting of type "metaobject_list". When I add this setting, my VS Code theme validator tells me I must have the property "metaobject_type"

 

I searched for a very long time to figure out what value should go into this `metaobject_type` property in my settings definition, but I believe it to be the Metaobject type handle. In this case, that should be `faqs` but the console keeps telling me it's Invalid Schema.

 

Here is my code setup:

ERROR: Invalid schema: setting with id="faq_metaobject_list" type is invalid

 

{
  "type": "metaobject_list",
  "id": "faq_metaobject_list",
  "label": "Metaobject",
  "metaobject_type": "faqs"
}

No matter what I put in here, it does not like it. 

 

Am I approaching this correctly? Is `metaobject_list` the right "type" here? If so, what should be the value for "metaobject_type"?

Replies 4 (4)
masebase
Excursionist
12 3 8

Thanks @Hesmerci 

 

I have scoured the internet and the documentation, but I have not found ANY examples of this code. Even ChatGPT isn't so useful. I think the metaobject features are so new that there is not a lot of content or examples out there yet. On your response....

 

  1. The Metaobject handle is indeed `faqs` See my screenshot:
    masebase_0-1725502093686.png

     

  2. Re: Schema validity in the theme settings - this is precisely where I am trying to define and develop it. I am self-taught by trial-and-error on building custom sections and theme settings. Where do I define this in the schema?
  3. Re: Theme validation - it seems that my local Shopify CLI doesn't know how to detect or isn't aware of valid values for the 

To be clear here are some more specifics:

  • I have a metaobject `faqs`, then I have successfully populated several entries in the stand-along FAQs metaobject. 
  • Then I have a separate metaobject `sales_landing_page` with many fields to fill in the template for different landing pages. In that definition I have a field of type metaobject referring to my `faqs` metaobject:
    masebase_1-1725502608314.png
  • In those entries, I can select many FAQs and I can see and verify they are associated with that object. 
    masebase_2-1725503065763.png
  • UP TO THIS POINT I'm good! Where I am getting blocked is adding a Setting to my new custom section on the template for this `sales_landing_page` the CLI won't validate the schema with or without `metaobject_type`

In fact, using Google to search the contents of shopify.dev yields that the exact phrase `metaobject_type` does not appear at on Shopify.dev at all

masebase_3-1725503436117.png

 

masebase
Excursionist
12 3 8

You know what - I think I have come to determine that the intellisense in VScode is several steps ahead of the actual CLI, theme validator and APIs. 

I found this "type" : "metaobject_list" from VScode intellisense, but it links to a page in the theme docs that has no mention of these types. 

 

https://shopify.dev/docs/storefronts/themes/architecture/settings/input-settings#metaobject_list

masebase_0-1725504864967.png

 

You can see in the list of specialized input settings that `metaobject` and `metaobject_list` are not shown anywhere.

theevilgenius
Shopify Partner
4 0 1

@masebase did you ever find a solution for this? I'm struggling as well.

masebase
Excursionist
12 3 8

@theevilgenius There is no `metaobject` or `metaobject_list` input type. The VScode Liquid intellisense extension led me astray and down this rabbit hole. So you cannot take this approach (right now). I assume that this is a planned addition in the future but not available today. I have an issue open with Shopify here.

 

What I did instead that works but is less ideal, is to manually associate my object records. So I had a metaobject for "faqs" and then in my other metaobject for "landing_pages" I just have a metaobject type on landing_pages that references "faqs" and then in each record I add, I manually select the FAQs that are associated with that landing page. 

 

It is not preferred for me, but it works. Ideally, I'd like to have new FAQs automatically associate with other new landing_page records because they match on a tag or category or something other than an explicit mapping between the two objects. 

 

Hope it helps!