🔍 コレクション/検索中級
フィーチャーコレクションのスライダー表示
複数のコレクションをカード形式でスライダーに並べて表示するセクション。自動再生、矢印ナビゲーション、ページネーション、スクロールバーをカスタマイズ可能。
用途
トップページやランディングページで、推奨コレクションを横スクロール形式で紹介したいとき。モバイル・タブレット・デスクトップのブレークポイントごとに表示数を調整できる。
設置場所
sections/featured-collections.liquid に配置し、テーマカスタマイザーの「セクションを追加」からドラッグ・ドロップで任意のページに追加する。ブロック設定でコレクションを選択すると自動的に collection-card スニペットで描画される。
注意点
Swiper.js ライブラリと swiper-slider カスタム要素が theme.liquid に事前にロードされていることが前提。コレクションを1つも選択しないと empty_state が表示されるため、プレビュー時は必ず1つ以上のコレクションを設定する。スライダーの autoplay 秒数が 0 に設定されると自動再生は無効になるため、自動スクロールを有効にするには数値を 1 以上に変更する。
コード
441 行 / liquid{% capture empty_state %}
{% for num in (1..6) %}
<div class="swiper-slide p-4 p-desktop-4">
<div class="collection-card text-center">
{% capture current %}{% cycle 1, 2, 3, 4, 5, 6 %}{% endcapture %}
{{ 'collection-' | append: current | placeholder_svg_tag: 'collection-card-img img-thumbnail mb-4' }}
<h3 class="collection-card-title h6 mb-1">
Collection {{ current }}
</h3>
</div>
</div>
{% endfor %}
{% endcapture %}
<swiper-slider
id="featured-collections-{{ section.id }}"
class="
featured-collections
swiper-slider
{{ section.settings.bg_color }}
{{ section.settings.bg_gradient }}
{{ section.settings.text_color }}
{{ section.settings.border_top_width | prepend: 'border-top-' }}
{{ section.settings.border_bottom_width | prepend: 'border-bottom-' }}
{{ section.settings.border_color }}
{{ section.settings.pt | prepend: 'pt-' }}
{{ section.settings.pb | prepend: 'pb-' }}
"
style="
--bs-bg-opacity: {{ section.settings.bg_opacity | append: '%' }};
--bs-border-opacity: {{ section.settings.border_opacity | append: '%' }};
"
data-slider-speed="{{ section.settings.slider_speed }}"
data-slider-navigation="{{ section.settings.slider_navigation }}"
data-slider-pagination="{{ section.settings.slider_pagination }}"
data-slider-scrollbar="{{ section.settings.slider_scrollbar }}"
data-slider-autoplay="{{ section.settings.slider_autoplay }}"
data-breakpoint-mobile="{{ section.settings.breakpoint_mobile }}"
data-breakpoint-tablet="{{ section.settings.breakpoint_tablet }}"
data-breakpoint-desktop="{{ section.settings.breakpoint_desktop }}">
<div
class="container"
style="max-width: {{ section.settings.container_max_width | append: 'px' }};">
{% render 'section-header' %}
<div class="swiper mx-n4 mx-desktop-n5 mt-n3 mt-desktop-n5">
<div class="swiper-wrapper">
{% for block in section.blocks %}
{% assign collection = block.settings.collection %}
<div class="swiper-slide p-4 p-desktop-5" {{ block.shopify_attributes }}>
{% render 'collection-card', collection: collection, block: block %}
</div>
{% else %}
{{ empty_state }}
{% endfor %}
</div>
<div class="swiper-controls">
<div class="swiper-pagination"></div>
<div class="swiper-scrollbar"></div>
<div class="swiper-button-prev">
{% render 'svg-icons', icon: 'chevron-left', size: 24 %}
</div>
<div class="swiper-button-next">
{% render 'svg-icons', icon: 'chevron-right', size: 24 %}
</div>
</div>
</div>
</div>
</swiper-slider>
{% schema %}
{
"name": "Featured collections",
"tag": "section",
"settings": [
{
"type": "header",
"content": "Styling"
},
{
"type": "select",
"id": "bg_color",
"label": "Background color",
"default": "bg-body",
"options": [
{ "value": "bg-primary", "label": "Primary" },
{ "value": "bg-secondary", "label": "Secondary" },
{ "value": "bg-body", "label": "Body" },
{ "value": "bg-white", "label": "White" }
]
},
{
"type": "range",
"id": "bg_opacity",
"label": "Background opacity",
"min": 0,
"max": 100,
"step": 1,
"default": 100,
"unit": "%"
},
{
"type": "select",
"id": "bg_gradient",
"label": "Background gradient",
"options": [
{ "value": "bg-gradient", "label": "Yes" },
{ "value": "", "label": "No" }
],
"default": ""
},
{
"type": "select",
"id": "text_color",
"label": "Text color",
"default": "text-body",
"options": [
{ "value": "text-primary", "label": "Primary" },
{ "value": "text-secondary", "label": "Secondary" },
{ "value": "text-body", "label": "Body" },
{ "value": "text-white", "label": "White" }
]
},
{
"type": "range",
"id": "border_top_width",
"label": "Border top width",
"default": 0,
"min": 0,
"max": 16,
"step": 1,
"unit": "px"
},
{
"type": "range",
"id": "border_bottom_width",
"label": "Border bottom width",
"default": 0,
"min": 0,
"max": 16,
"step": 1,
"unit": "px"
},
{
"type": "select",
"id": "border_color",
"label": "Border color",
"default": "border-body",
"options": [
{ "value": "border-primary", "label": "Primary" },
{ "value": "border-secondary", "label": "Secondary" },
{ "value": "border-body", "label": "Body" },
{ "value": "border-white", "label": "White" }
]
},
{
"type": "range",
"id": "border_opacity",
"label": "Border opacity",
"min": 0,
"max": 100,
"step": 1,
"default": 100,
"unit": "%"
},
{
"type": "text",
"id": "container_max_width",
"label": "Container max-width (px)",
"info": "Leave empty to use the global container width"
},
{
"type": "header",
"content": "Header"
},
{
"type": "text",
"id": "header_title",
"label": "Title",
"default": "Featured Collections"
},
{
"type": "select",
"id": "header_title_font_size",
"label": "Title font-size",
"default": "h2",
"options": [
{ "value": "h1", "label": "H1" },
{ "value": "h2", "label": "H2" },
{ "value": "h3", "label": "H3" },
{ "value": "h4", "label": "H4" },
{ "value": "h5", "label": "H5" },
{ "value": "h6", "label": "H6" }
]
},
{
"type": "richtext",
"id": "header_description",
"label": "Description (optional)",
"default": "<p>Add on optional description for this section</p>"
},
{
"type": "select",
"id": "header_description_font_size",
"label": "Description font-size",
"default": "fs-md",
"options": [
{ "value": "fs-sm", "label": "sm" },
{ "value": "fs-md", "label": "md" },
{ "value": "fs-lg", "label": "lg" },
{ "value": "fs-xl", "label": "xl" },
{ "value": "fs-xxl", "label": "xxl" }
]
},
{
"type": "header",
"content": "Slider"
},
{
"type": "range",
"id": "slider_speed",
"label": "Speed",
"default": 300,
"min": 0,
"max": 2000,
"step": 100,
"unit": "ms"
},
{
"type": "checkbox",
"id": "slider_navigation",
"label": "Show navigation (arrows)",
"default": true
},
{
"type": "checkbox",
"id": "slider_pagination",
"label": "Show pagination",
"default": true
},
{
"type": "select",
"id": "slider_pagination_type",
"label": "Pagination type",
"default": "bullets",
"options": [
{ "value": "bullets", "label": "Bullets" },
{ "value": "fraction", "label": "Fraction" }
],
"info": "NOTE: This feature is supported only in our Premium Shopify Themes. [Browse premium themes](https://www.kondasoft.com/collections/shopify-themes)"
},
{
"type": "checkbox",
"id": "slider_scrollbar",
"label": "Show scrollbar",
"default": true
},
{
"type": "checkbox",
"id": "slider_partial_slides_mobile",
"label": "Partial slides on mobile",
"default": false,
"info": "NOTE: This feature is supported only in our Premium Shopify Themes. [Browse premium themes](https://www.kondasoft.com/collections/shopify-themes)"
},
{
"type": "range",
"id": "slider_autoplay",
"label": "Autoplay",
"min": 0,
"max": 10,
"default": 0,
"unit": "sec",
"info": "Selecing \"0\" will disable autoplay."
},
{
"type": "header",
"content": "Collection card"
},
{
"type": "select",
"id": "collection_card_text_align",
"label": "Text align",
"default": "text-center",
"options": [
{ "value": "text-start", "label": "Left" },
{ "value": "text-center", "label": "Center" }
]
},
{
"type": "select",
"id": "collection_card_img_orientation",
"label": "Image orientation",
"default": "ratio-4x3",
"options": [
{ "group": "Adapt", "value": "adapt", "label": "Adapt" },
{ "group": "Square", "value": "ratio-1x1", "label": "1x1" },
{ "group": "Horizontal", "value": "ratio-4x3", "label": "4x3" },
{ "group": "Horizontal", "value": "ratio-16x9", "label": "16x9" },
{ "group": "Horizontal", "value": "ratio-21x9", "label": "21x9" },
{ "group": "Vertical", "value": "ratio-3x4", "label": "3x4" },
{ "group": "Vertical", "value": "ratio-9x16", "label": "9x16" },
{ "group": "Vertical", "value": "ratio-9x21", "label": "9x21" }
]
},
{
"type": "select",
"id": "collection_card_img_border",
"label": "Image border",
"default": "img-thumbnail",
"options": [
{ "value": "", "label": "None" },
{ "value": "rounded", "label": "Rounded" },
{ "value": "img-thumbnail", "label": "Thumbnail" }
]
},
{
"type": "checkbox",
"id": "collection_card_show_title",
"label": "Show title",
"default": true
},
{
"type": "select",
"id": "collection_card_title_font_size",
"label": "Title font-size",
"default": "fs-lg",
"options": [
{ "value": "fs-sm", "label": "sm" },
{ "value": "fs-md", "label": "md" },
{ "value": "fs-lg", "label": "lg" },
{ "value": "fs-xl", "label": "xl" },
{ "value": "fs-xxl", "label": "xxl" }
]
},
{
"type": "select",
"id": "collection_card_title_position",
"label": "Title position",
"default": "collection-card-title-bottom",
"options": [
{ "value": "collection-card-title-normal", "label": "Normal" },
{ "value": "collection-card-title-left", "label": "Left" },
{ "value": "collection-card-title-bottom", "label": "Bottom" }
],
"info": "NOTE: This feature is supported only in our Premium Shopify Themes. [Browse premium themes](https://www.kondasoft.com/collections/shopify-themes)"
},
{
"type": "checkbox",
"id": "collection_card_show_product_count",
"label": "Show product count",
"default": true
},
{
"type": "header",
"content": "Breakpoints",
"info": "Adjust items per slide based on the screen resolution"
},
{
"type": "range",
"id": "breakpoint_mobile",
"label": "Mobile (<600px)",
"min": 1,
"max": 3,
"step": 1,
"default": 1
},
{
"type": "range",
"id": "breakpoint_tablet",
"label": "Tablet (≥600px)",
"min": 1,
"max": 4,
"step": 1,
"default": 2
},
{
"type": "range",
"id": "breakpoint_desktop",
"label": "Desktop (≥1200px)",
"min": 1,
"max": 6,
"step": 1,
"default": 4
},
{
"type": "header",
"content": "Spacing"
},
{
"type": "range",
"id": "pt",
"label": "Top",
"min": 0,
"max": 20,
"step": 1,
"default": 10
},
{
"type": "range",
"id": "pb",
"label": "Bottom",
"min": 0,
"max": 20,
"step": 1,
"default": 10
}
],
"blocks": [
{
"type": "collection",
"name": "Collection",
"settings": [
{
"type": "collection",
"id": "collection",
"label": "Collection"
},
{
"type": "image_picker",
"id": "img",
"label": "Image",
"info": "Optional - Leave empty to use the default collection image"
},
{
"type": "text",
"id": "title",
"label": "Title",
"info": "Optional - Leave empty to use the default collection title"
}
]
}
],
"disabled_on": {
"groups": ["header", "footer"]
},
"presets": [
{
"name": "Featured collections"
}
]
}
{% endschema %}出典・ライセンス
- Repository:
- https://github.com/kondasoft/ks-bootshop
- License:
- MIT
このコードは kondasoft 著作の MIT ライセンスソースです。 原本の著作権は kondasoft が保有します。日本語訳は ALSEL によるものです。
関連項目
🔍 コレクション/検索初級
ページネーションの表示
ページネーションUI(前へ・次へ、ページ番号)を paginate オブジェクトから描画するスニペット。デフォルトのページネーション形式で複数ページに分割したコンテンツをナビゲートできる。
📁 shopify-code-snippets·MIT·6 行
🔍 コレクション/検索初級
ページネーションの現在位置表示
コレクションや検索結果の一覧ページで、現在のページ番号と全ページ数を表示する。Shopify の多言語対応翻訳キーを使用して、言語ごとに自動で表記を切り替える。
📁 shopify-code-snippets·MIT·6 行
🔍 コレクション/検索中級
検索結果のペジネーション比較
検索結果を paginate タグで複数パターン分割して表示するテンプレート。デフォルトペジネーションと window_size:1 オプション指定の両方の書き方を示しており、ページネーション動作の違いを検証するサンプルコード。
📁 theme-tools·MIT·12 行
🔍 コレクション/検索初級
検索結果のページネーション設定
検索結果を paginate タグでページ分割し、複数の window_size 設定を並べて出力する方法。28件単位のペーグネーションと、ウィンドウサイズを明示的に指定した設定の2パターンを示している。
📁 theme-tools·MIT·12 行
🔍 コレクション/検索初級
コレクションページの商品ギャラリー
コレクション内の商品を3列のテーブルレイアウトで表示するテンプレート。各商品にサムネイル、タイトル、価格(セール時は定価を取消線)を表示し、ページネーションに対応する。
📁 liquid·MIT·20 行
🔍 コレクション/検索初級
コレクションページの商品一覧
コレクション内の商品を一覧表示し、商品画像・タイトル・説明文・価格帯をカード状に並べる。ページネーション機能で20件ごとに分割表示する。
📁 liquid·MIT·23 行