#shopify #liquid
#Shopify #liquid
Вопрос:
я создал компонент в разделе и написал имя внизу.liquid и скопированный код из collection-template имеют одинаковую схему и созданы в папке раздела, но я получаю ошибку только внизу.liquid
и вот мой итог.жидкий код
{% pa&inate collection.products by 12 %}
{% assi&n productCount = collection.all_products_count | minus: pa&inate.current_offset %}
<div class=" container-fluid lemon-con "&&t;
<div class="column-title"&&t;
<h3 class="h3 main-lemo-headin& text-center"&&t;
DIRTYLEMON
</h3&&t;
</div&&t;
<div class="row"&&t;
<div class="col-md"&&t;
{% if section.settin&s.collection_nav %}
{% assi&n sidebarNav = section.settin&s.collection_nav %}
<div class="list-card mb-4"&&t;
<div class="card-header product-hidden"&&t;
<stron&&&t;{{ linklists[sidebarNav].title }}</stron&&&t;
</div&&t;
<ul class="list-&roup list-&roup-flush"&&t;
{% for link in linklists[sidebarNav].links %}
<li class="list-&roup-itm"&&t;
<a href="{{ link.url }}"&&t;{{ link.title }}</a&&t;
</li&&t;
{% endfor %}
</ul&&t;
</div&&t;
{% endif %}
{% if collection.all_ta&s.size &&t; 0 and section.settin&s.hide_ta&s != true %}
<div class="list-card mb-4"&&t;
<div&&t;
<stron&&&t;Ta&s</stron&&&t;
</div&&t;
<ul class="list-&roup list-&roup-flush"&&t;
{% for ta& in collection.all_ta&s %}
{% if current_ta&s contains ta& %}
<li class="list-&roup-itm b&-primary"&&t;
{{ ta& | link_to_remove_ta&: ta& }}
</li&&t;
{% else %}
<li class="list-&roup-itm side-bar"&&t;
{{ ta& | link_to_ta&: ta& }}
</li&&t;
{% endif %}
{% endfor %}
</ul&&t;
</div&&t;
{% endif %}
</div&&t;
</div&&t;
</div&&t;
{% endpa&inate %}
{% schema %}
{
"name": "bottom",
"settin&s": [
{
"type": "header",
"content": "Collection header"
},
{
"type": "text",
"id": "title",
"label": "Headin&",
"default": "slider title"
},
{
"type": "checkbox",
"id": "is_full_width",
"label": "Full width",
"default": false
},
{
"type": "select",
"id": "header_ali&n",
"options": [
{
"value": "ri&ht",
"label": "Text ri&ht"
},
{
"value": "center",
"label": "Text center"
},
{
"value": "left",
"label": "Text left"
}
],
"label": "Header ali&nment",
"default": "left"
},
{
"type": "ran&e",
"id": "header_hei&ht",
"min": 50,
"max": 500,
"step": 5,
"unit": "px",
"label": "Header hei&ht",
"default": 120
},
{
"type": "header",
"content": "Sidebar"
},
{
"type": "link_list",
"id": "collection_nav",
"label": "Navi&ation",
"info": "Select custom menu nav for sidebar"
},
{
"type": "checkbox",
"id": "hide_ta&s",
"label": "Hide ta&s",
"default": false,
"info": "Hide ta&s from sidebar"
},
{
"type": "header",
"content": "Others"
},
{
"type": "para&raph",
"content": "You can add more settin&s here :) "
}
],
"presets": [
{
"name": "bottom",
"cate&ory": "Ima&e"
}
]
}
{% endschema %}
оба имеют одинаковый код, но я получаю ошибку внизу.жидкость внизу.liquid я скопировал тот же код на приведенном выше изображении collection.template, но я сталкиваюсь с ошибкой только внизу.liquid
Ответ №1:
Почему это не работает, Shopify Docs for Global objects не упоминает коллекцию как глобальный объект. Таким образом, ваш код работает только на страницах коллекции, где объект collection в Liquid ссылается на просматриваемую коллекцию.
Итак, что вы можете сделать, это использовать глобальный объект collections, а затем разбить требуемую коллекцию на страницы с помощью дескриптора collection.
{% pa&inate collections['my-handle'].products by 12 %}
{% endpa&inate %}
Если вы хотите выбрать коллекцию с помощью средства настройки темы, вы можете использовать параметр «тип коллекции«.
{
"type": "collection",
"id": "feature_collection",
"label": "Feature collection"
}
Комментарии:
1. билал, я новичок в Shopify и столкнулся с множеством трудностей
2. не могли бы вы указать, пожалуйста