shopify - 将产品系列分配给 Shopify 中自定义创建的产品系列页面?
问题描述
我在 Shopify 上使用免费的 Venture 主题,并且正在尝试制作自定义收藏页面。
我在 stackoverflow 中找到了一个解决方案,但它能够在某个地方提供帮助。 如何将 collection.liquid 添加到现有页面?
解决方案的概要是: 复制collection.liquid 中的所有内容并将其粘贴到一个新片段中(假设您将其称为collection-copy.liquid)。然后,在要添加收藏页面的页面中,只需添加 {% include 'collection-copy' %}
这个解决方案效果很好,但对我来说还有一个问题。在自定义创建的页面中显示“抱歉,此集合中没有产品” 在同一页面的自定义中,有一个“集合”部分。但是在“收藏”部分没有选择收藏的选项。只有“启用标签过滤”和“启用排序”复选框。
网页:https ://mottomfreedom.com/pages/less-is-more
您是否知道使用此自定义创建的片段分配集合?
{% paginate collections[settings.frontpage_collection].products by 20 %}
<div class="page-width">
<header class="grid medium-up--grid--table section-header small--text-center">
<div class="grid__item medium-up--one-half section-header__item">
<h1 class="section-header__title">
{{ collection.title }}
{% if current_tags %}
– {% assign title_tags = current_tags | join: ', ' %}
{{ title_tags }}
{% endif %}
</h1>
{% if collection.description != blank %}
<div class="section-header__subtext rte">
{{ collection.description }}
</div>
{% endif %}
</div>
<div class="grid__item medium-up--one-half medium-up--text-right section-header__item">
{% section 'collection-filters' %}
</div>
</header>
<div class="grid grid--no-gutters grid--uniform">
{% for product in collection.products %}
<div class="grid__item small--one- medium-up--one-third">
{% include 'product-card', product: product %}
</div>
{% else %}
{% comment %}
Add default products to help with onboarding for collections/all only.
The onboarding styles and products are only loaded if the
store has no products.
{% endcomment %}
{% if shop.products_count == 0 %}
<div class="grid__item">
<div class="grid grid--no-gutters grid--uniform">
{% assign collection_index = 1 %}
{% for i in (1..10) %}
{% case i %}
{% when 7 %}
{% assign collection_index = 1 %}
{% when 8 %}
{% assign collection_index = 2 %}
{% when 9 %}
{% assign collection_index = 3 %}
{% when 10 %}
{% assign collection_index = 4 %}
{% endcase %}
<div class="grid__item small--one-half medium-up--one-fifth">
<a href="/admin/products" class="product-card">
<div class="product-card__image-container">
<div class="product-card__image-wrapper">
<div class="product-card__image">
{% capture current %}{% cycle 1, 2, 3, 4, 5, 6 %}{% endcapture %}
{{ 'product-' | append: current | placeholder_svg_tag: 'placeholder-svg' }}
</div>
</div>
</div>
<div class="product-card__info">
<div class="product-card__name">{{ 'homepage.onboarding.product_title' | t }}</div>
<div class="product-card__price">
$19.99
</div>
</div>
<div class="product-card__overlay">
{% assign view_string_length = 'products.product.view' | t | size %}
<span class="btn product-card__overlay-btn {% if view_string_length > 8 %} btn--narrow{% endif %}">{{ 'products.product.view' | t }}</span>
</div>
</a>
</div>
{% assign collection_index = collection_index | plus: 1 %}
{% endfor %}
</div>
</div>
{% else %}
{% comment %}
If collection exists but is empty, display message
{% endcomment %}
<div class="grid__item small--text-center">
<p>{{ 'collections.general.no_matches' | t }}</p>
</div>
{% endif %}
{% endfor %}
</div>
{% if paginate.pages > 1 %}
<div class="pagination">
{{ paginate | default_pagination | replace: '« Previous', '←' | replace: 'Next »', '→' }}
</div>
{% endif %}
</div>
{% endpaginate %}
解决方案
您在接受答案之前给了一些时间是对的:))该解决方案有效,但迫使我为每个集合创建 1 页和 4 个液体文件。最后,我发现像“collection.list”这样的部分并没有指向我创建的页面。我认为您在答案的开头就在谈论这个:)
在那之后,我找到了一个更好的解决方案。只需创建一个新的 section.liquid 文件并将其放入带有“if”语句的“collection.liquid”即可解决我的问题。
{% if collection.handle == 'less-is-more' %}
{% section 'custom-featured-products-LESSisMORE' %}
{% endif %}
但无论如何,我很感激你的兴趣。非常感谢戴夫。
推荐阅读
- twilio - 验证在 Twilio 中收到的 SMS 来自真实手机,而不是欺骗性的 POST 请求
- javascript - 是否可以在 JSON 文件中保留某些内容?(不和谐.JS)
- html - 将 div 彼此对齐,一个与 img
- c - 为 SIGTSTP 信号配置处理程序以显示消息但不终止当前进程
- windows - 我不能用 python 播放音频
- android - 当我按下返回时,如何刷新 recylverview 项目?
- javascript - jquery在单击时将1添加到变量然后插入到数据库
- c - 删除字符串数组中的空格并计算空格 C
- python - 无法从 shopee.com 抓取最畅销的产品
- arrays - 制作一个快速将结构附加到数组的按钮