如何在Shopify单个MetaObject页面上获取MetaObject值

huangapple go评论54阅读模式
英文:

How Do I Get MetaObject Values On Single MetaObject Page In Shopify

问题

我正在使用Shopify中的metaObjects。我已创建了一个名为“Projects”的metaObject。我创建了一个名为“Projects”的页面,通过Liquid代码显示了这些保存的项目。它按照“Projects”页面的要求工作,但现在我想在单独的页面上显示每个项目的详细信息。我应该如何处理?比如,我应该创建一个页面并在其中设置一个模板,在该模板中获取metaObject的句柄以显示其详细信息。我遇到了一个问题,就是如何调用同一个单独的页面来显示所有项目的详细信息并显示其详细信息。请问有人能指导一下如何在单个项目页面上获取每个metaObject的值。谢谢。

英文:

I am using metaObjects in shopify. I have created a metaObject name "Projects" . I created a page "Projects" to display those saved projects through liquid code. It is working as per the requirement on Projects page but now i want to display each project detail on single page. How do i approach this ? Like should i create a page and set a template on it and in that template , fetch the metaobject handle to display its details . I am facing issue like how do i call the same single page for all projects details and display its details. Can someone please guide what is the possible way to get each metaObject values on single project page .

Thanks

答案1

得分: 3

在Shopify管理后台创建了元对象定义之后,接下来需要在项目页面上创建另一个定义,字段类型为"metaobject"。我为了实现这个目标,对产品进行了以下操作:

  1. 创建了一个"benefit"的元对象,并添加了一个单一文本字段。
  2. 为产品创建了一个"metafield",其名称为"mixed reference list",并引用了我创建的"benefits"元对象。
  3. 在产品管理中,通过新的"metafield"添加了一些"benefits"。
  4. 添加了Liquid代码,以显示附加到页面的"benefits"列表:
<ul>
{% for item in product.metafields.custom.benefits.value -%}
<li>{{ item.benefits }}</li>
{%- endfor %}
</ul>

希望这对您有所帮助!

英文:

After you have created your meta object definition in the Shopify admin you need to then create another definition on your project page with the field type of metaobject I did the following for products to accomplish this :

  1. Created meta-object of benefit and added a single text field.

  2. Created a metafield for product which was called a mixed reference list and referenced the benefits meta object i created.

  3. Added a couple of benefits with the new meta field in the product admin.

  4. Added liquid to display the list of benefits attached to the page :

    <ul>
    {% for item in product.metafields.custom.benefits.value -%}
    <li> {{ item.benefits }}</li>
    {%- endfor %}
    </ul>

I hope this helps!

huangapple
  • 本文由 发表于 2023年2月18日 17:49:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/75492491.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定