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
Tourist
8 2 5

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 2 (2)
masebase
Tourist
8 2 5

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
Tourist
8 2 5

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.