[英]Creating a shopify template with unique content blocks
I have an ecommerce site, and I'm trying to create a "Lookbook" template. 我有一个电子商务网站,正在尝试创建“ Lookbook”模板。 I want my client to be able to create a new lookbook (just as a simple page with a template of "page.lookbook" or similar), then be able to go into the page admin and select and upload images, links, descriptions etc.
我希望我的客户能够创建一个新的外观簿(就像一个带有“ page.lookbook”或类似模板的简单页面一样),然后能够进入页面管理并选择并上传图像,链接,描述等。
So far I have: 到目前为止,我有:
page.lookbook.liquid
-> calls in the section, lookbook-template.liquid
page.lookbook.liquid
>在部分lookbook-template.liquid
调用 lookbook-template.liquid
has an HTML template lookbook-template.liquid
具有HTML模板 It also has this schema: 它还具有以下架构:
{% schema %}
{
"name": "Lookbook",
"blocks": [
{
"type": "Image",
"name": "Lookbook image",
"settings":[
{
"type": "image_picker",
"id": "img",
"label": "Image"
},
{
"type": "text",
"id": "description",
"label": "Description",
"default": "<p>You can write <em>html</em> <a href=\"https://example.com/\">in here</a>!</p>"
}
]
}
]
}
{% endschema %}
This way, my client can use the simple admin tools to add a new image block. 这样,我的客户可以使用简单的管理工具来添加新的图像块。 Very nice!
非常好!
However, this method means that every single lookbook gets the SAME image data as whatever I apply to the lookbook-template.liquid
, and this isn't ideal at all. 但是,此方法意味着每个外观书都像我应用于
lookbook-template.liquid
一样获取相同的图像数据,这根本不是理想的。
What am I doing wrong here, and what's the right solution? 我在这里做错了什么,正确的解决方案是什么? I want one template that the client choose to attach to a page, and then for each template to have a unique set of images, links and descriptions that the client creates.
我希望客户端选择一个模板附加到页面,然后让每个模板具有一组由客户端创建的独特图像,链接和描述。
Unfortunately, section won't work to get some different content for each page with lookbook.page template. 不幸的是,使用lookbook.page模板,section无法为每个页面获取一些不同的内容。
A solution would be to install (or create) an app to manage metafields attached to pages. 一种解决方案是安装(或创建)应用程序以管理附加到页面的元字段。 Then you can use metafields in your template.
然后,您可以在模板中使用元字段。
Metafields is a way to add some extra fields in database: https://help.shopify.com/themes/liquid/objects/metafield 元字段是一种在数据库中添加一些额外字段的方法: https ://help.shopify.com/themes/liquid/objects/metafield
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.