Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
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:
or something along the lines of...
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.
Hey @Mirror_of_Exist
Have you tried this you mentioned in your post. Is it not work?
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."
Where you put this code in the theme editor?
Here:
Copying and pasting the "tab text" here results in :
----
{{ product.metafields.custom.my_metaobject.value.test_text.value }}
----
Thank you.
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 -%}
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024