在特色系列中购买“视图集”按钮

时间:2017-05-31 07:44:57

标签: shopify

我正在为网店提供基本内容,并尝试在主页上的精选集合中添加“查看集合”按钮。在文档中它说明通常我只需要做collection.url并获取url。但它似乎没有用。谁能说我做错了什么? (https://help.shopify.com/themes/liquid/objects/collection#collection-url

{% if section.settings.show_view_all %}
    <hr class="hr--clear">
    <div class="text-center">
      <a href="{{ section.settings.featured_collection.url }}" class="btn">
        {{ 'collections.general.view_all' | t }}
      </a>
    </div>
{% endif %}
  
  
</div>

{% schema %}
  {
    "name": "Featured collection",
    "class": "index-section",
    "settings": [
      {
        "type": "text",
        "id": "title",
        "label": "Heading",
        "default": "Featured collection"
      },
      {
        "type": "collection",
        "id": "featured_collection",
        "label": "Collection"
      },

2 个答案:

答案 0 :(得分:1)

我像这样包装h2标签:

{% if section.settings.title != blank %}
  <a href="/collections/{{ section.settings.home_page_featured_products }}"><h2 class="small--text-center">{{ section.settings.title | escape }}</h2></a>
{% endif %}

由于我从来没有打算让收藏款有所不同,所以这对我有用。你的旅费可能会改变。这是使用“简单”主题。

答案 1 :(得分:0)

您应该检查集合设置类型: https://help.shopify.com/themes/development/theme-editor/settings-schema#collection

  

商家从下拉列表中选择的选项的输出是集合的句柄。

所以,而不是:

{{ section.settings.featured_collection.url }}

你应该使用: {{ collections[section.settings.featured_collection].url }}