简体   繁体   English

如何在布局中使用 Shopify 部分?

[英]How to use a Shopify Section across a Layout?

I have a section with content that can be edited from the Shopify Customizer.我有一个部分包含可以从 Shopify 定制器编辑的内容。 I use this section across multiple pages, but the content remains the same.我在多个页面中使用此部分,但内容保持不变。

Is there a way to instead bind this section to a whole layout?有没有办法将此部分绑定到整个布局?

Because when you update the content, you have it re-enter it on every single page template that uses this section.因为当您更新内容时,您会在使用此部分的每个页面模板上重新输入它。 I can have static HTML across all page templates that use a layout, but this isn't useful because the content needs to be editable from the Shopify Customizer.我可以在所有使用布局的页面模板中使用 static HTML,但这没有用,因为内容需要从 Shopify 定制器进行编辑。

You can have a section across a layout after all.毕竟你可以在布局中有一个部分。

I was doing我在做

layout/my-new-layout.liquid:布局/我的新layout.liquid:
{% render 'section-component.liquid' %}

when I was supposed to be doing当我应该做的时候

layout/my-new-layout.liquid:布局/我的新layout.liquid:
{% section 'section-component.liquid' %}

For reference以供参考

If you're trying to convert a template-only section to a layout-only section...如果您尝试将仅模板部分转换为仅布局部分...

  1. Remove the section JSON data from the template: templates/page.your-template.json .从模板中删除部分 JSON 数据: templates/page.your-template.json
  2. Add a {% section 'your-section' %} in the layout (ie layout/my-new-layout.liquid ).在布局中添加{% section 'your-section' %} (即layout/my-new-layout.liquid )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM