Have your say in Community Polls: What was/is your greatest motivation to start your own business?

Trying to link to metaobjects pages or use a metaobject url field to create a link

Trying to link to metaobjects pages or use a metaobject url field to create a link

Mirror_of_Exist
Excursionist
16 0 3

I'm trying to create links to metaobjects using the theme editor.

 

I'm using OS2.0, Broadcast theme, and have created a metaobject accessible via:

 

{{ product.metafields.custom.my_metaobject }}

 

and also a URL metaobject to experiment with at:

 

{{ product.metafields.custom.my_metaobject.value.example_link }}

 

In the theme editor, while editing a product template, I would to achieve either of the following:

 

a) Create a link to my_metaobject (ie: https://mystore.my-shopify.com/my_metaobject/abcd)

b) Highlight some text and have the path set to example_link.value

 

Trying to do something like this as the URL value for a link:

http://abc.com/{{ product.metafields.custom.my_metaobject.value.example_link.system.url }}

or

https://abc.com/{{ product.metafields.custom.my_metaobject.system.url }}

or use

{{ product.metafields.custom.my_metaobject.value.example_link.value }}

In an attempt to create either a link to the metaobject or use the URL field to do something useful returns the errors:

  • "Dynamic source 'product.metafields.custom.my_metaobject.value.example_link.value' is type: URL. Setting 'raw_content_1' can only use types: Text, Integer, Decimal, Measurement, Datetime, Rating, Money, Single-line Text List, Multi-line Text, Rich Text."

or something along the lines of...

 

  • "Dynamic source 'product.metafields.custom.my_metaobject.value.example_link.system.url' is invalid."
  • "Dynamic source 'product.metafields.custom.my_metaobject.system.url' is invalid."

Is there any way to create links in the theme editor without hacking the theme liquid files?

 

I'd also love to be able to link to the publicly accessible metaobject object pages themselves (eg: myshop.com/my_metaobject/abc) when adding the metaobjects to the rich text fields, but the best I can do is get the title name of metaobject to display, with no way to ever create a link to the metaobject's own object page.

 

I'd be happy with either a way to highlight some text and have the URL come from a metaobject URL field, or just insert a metaobject reference and have it link to the metaobject page itself. But currently it seems the only way I can put links into a rich text field is by using a rich text metaobject.

 

Any tips? The closest I have seen on here is this but it doesn't seem to apply.

Replies 5 (5)

Sonya_2025
Shopify Partner
294 36 53

Hey @Mirror_of_Exist 

Have you tried this  you mentioned in your post. Is it not work?

Please let me know if it works by giving it a Like or marking it as a solution!
Feel free to reach out.Get Shopify free trial 1$/mon
 EMAIL ME  Motivate me by  PAY ME
Mirror_of_Exist
Excursionist
16 0 3

I can't get it to work, likely because I'm not using a repeater block. I have tried a bunch of variations trying to get something to take however:

 

 

/pages/my_metaobject/{{block.my_metaobject.value}}

 

Error: "Dynamic source 'block.my_metaobject.value' is invalid." 

 

and

 

/pages/my_metaobject/{{product.metafields.custom.my_metaobject.value}}

 

Error: "Dynamic source 'product.metafields.custom.my_metaobject.value' is type: Metaobject Reference. Setting 'raw_content_1' can only use types: Text, Integer, Decimal, Measurement, Datetime, Rating, Money, Single-line Text List, Multi-line Text, Rich Text."

 

and

 

/pages/creators/{{block.repeater.custom.my_metaobject.value}}

 

Error: "Dynamic source 'block.repeater.custom.my_metaobject.value' is invalid."

Sonya_2025
Shopify Partner
294 36 53

Where you put this code in the theme editor? 

Please let me know if it works by giving it a Like or marking it as a solution!
Feel free to reach out.Get Shopify free trial 1$/mon
 EMAIL ME  Motivate me by  PAY ME
Mirror_of_Exist
Excursionist
16 0 3

Here:

Mirror_of_Exist_0-1716527524455.png

Copying and pasting the "tab text" here results in :

----

  • Test A
  • Test B
  • Test C

{{ product.metafields.custom.my_metaobject.value.test_text.value }}

----

 

Thank you.

Jamie_Baker
Shopify Partner
1 0 0

This really should be in the Shopify docs. After a short battle this works for me (left the loop in for context):

 

 

{%- for entry in shop.metaobjects.help_center_content.values -%}
   {%- if entry.category_tab.value.tab_title == tab_title -%}
      <a href="{{ shop.url }}{{ entry.system.url }}">{{ entry.title }}</a>
   {%- endif -%}
{%- endfor -%}