Shopify themes, liquid, logos, and UX
Hello!
My site is www.faithandyou.in
There is a custom cellections liquid file i have on my site.
It loops and autoplays the categories every 2.5 seconds but i need help.
The collection list is too tiny on mobile
And on desktop the images get cut off on the right side
This is my custom-collection-list.liquid! HOW CAN WE FIX THIS???
{{ 'section-collection-list.css' | asset_url | stylesheet_tag }} {{ 'component-card.css' | asset_url | stylesheet_tag }} {{ 'component-slider.css' | asset_url | stylesheet_tag }} {%- style -%} .section-{{ section.id }}-padding { padding-top: {{ section.settings.padding_top | times: 0.75 | round: 0 }}px; padding-bottom: {{ section.settings.padding_bottom | times: 0.75 | round: 0 }}px; } @media screen and (min-width: 750px) { .section-{{ section.id }}-padding { padding-top: {{ section.settings.padding_top }}px; padding-bottom: {{ section.settings.padding_bottom }}px; } } {%- endstyle -%} {%- liquid assign columns_mobile_int = section.settings.columns_mobile | plus: 0 assign show_mobile_slider = false if section.settings.swipe_on_mobile and section.blocks.size > columns_mobile_int assign show_mobile_slider = true endif -%} <!-- Link Swiper's CSS --> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css" /> <style> .mySwiper { padding-bottom: 30px; } .mySwiper .swiper-button-prev, .mySwiper .swiper-button-next { display: block; width: 50px; height: 50px; display: flex; align-items: center; justify-content: center; background: white; color: black; } .mySwiper .swiper-button-prev::after, .mySwiper .swiper-button-next::after { font-size: 22px; } .mySwiper .swiper-pagination .swiper-pagination-bullet { width: 15px; height: 15px; background: #d07e13; } </style> <div class="color-{{ section.settings.color_scheme }} gradient grid--{{ section.settings.columns_desktop }}-col-desktop"> <div class="collection-list-wrapper isolate{% if show_mobile_slider %} page-width-desktop{% endif %}{% if section.settings.title == blank %} no-heading{% endif %}{% if section.settings.show_view_all == false or section.blocks.size > collections.size %} no-mobile-link{% endif %} section-{{ section.id }}-padding"> {%- unless section.settings.title == blank -%} <div class="title-wrapper-with-link{% if show_mobile_slider %} title-wrapper--self-padded-tablet-down{% else %} title-wrapper--self-padded-mobile{% endif %} title-wrapper--no-top-margin"> <h2 id="SectionHeading-{{ section.id }}" class="collection-list-title inline-richtext {{ section.settings.heading_size }}{% if settings.animations_reveal_on_scroll %} scroll-trigger animate--slide-in{% endif %}" > {{ section.settings.title }} </h2> {%- if section.settings.show_view_all and show_mobile_slider -%} <a href="{{ routes.collections_url }}" id="ViewAll-{{ section.id }}" class="link underlined-link large-up-hide{% if settings.animations_reveal_on_scroll %} scroll-trigger animate--slide-in{% endif %}" aria-labelledby="ViewAll-{{ section.id }} SectionHeading-{{ section.id }}" > {{- 'sections.collection_list.view_all' | t -}} </a> {%- endif -%} </div> {%- endunless -%} {% comment %} <slideshow-component class="slider-mobile-gutter slider-component-desktop {% if settings.animations_reveal_on_scroll %} scroll-trigger animate--slide-in{% endif %}"> <ul class="slideshow slider slider--everywhere custom-collection-listing collection-list contains-card contains-card--collection{% if settings.card_style == 'standard' %} contains-card--standard{% endif %} grid grid--{{ section.settings.columns_desktop }}-col-desktop grid--{{ section.settings.columns_mobile }}-col-tablet-down{% if section.settings.swipe_on_mobile %} slider slider--tablet grid--peek{% endif %} collection-list--{{ section.blocks.size }}-items" id="Slider-{{ section.id }}" role="list" > {%- liquid assign columns = section.blocks.size if columns > 3 assign columns = 3 endif -%} {%- for block in section.blocks -%} <li id="Slide-{{ section.id }}-{{ forloop.index }}" class=" slideshow__slide slider__slide grid__item{% if show_mobile_slider %} slider__slide{% endif %}{% if block.settings.collection.featured_image == nil %} collection-list__item--no-media{% endif %}{% if settings.animations_reveal_on_scroll %} scroll-trigger animate--slide-in{% endif %}" {{ block.shopify_attributes }} {% if settings.animations_reveal_on_scroll %} data-cascade style="--animation-order: {{ forloop.index }};" {% endif %} > {%- assign placeholder_image_index = forloop.index0 | modulo: 4 | plus: 1 -%} {%- assign placeholder_image = 'collection-apparel-' | append: placeholder_image_index -%} {% render 'custom-card-collection', card_collection: block.settings.collection, card_collection_image: block.settings.card_collection_image, media_aspect_ratio: section.settings.image_ratio, columns: columns, placeholder_image: placeholder_image %} </li> {%- endfor -%} </ul> <div class="slider-buttons no-js-hidden"> <div class="slider-counter caption"> <span class="slider-counter--current">1</span> <span aria-hidden="true"> / </span> <span class="visually-hidden">{{ 'general.slider.of' | t }}</span> <span class="slider-counter--total">{{ products_to_display }}</span> </div> <div class="slider-button-button"> <button type="button" class="slider-button slider-button--prev" name="previous" aria-label="{{ 'sections.slideshow.previous_slideshow' | t }}" aria-controls="Slider-{{ section.id }}" > {% render 'icon-caret' %} </button> <button type="button" class="slider-button slider-button--next" name="next" aria-label="{{ 'sections.slideshow.next_slideshow' | t }}" aria-controls="Slider-{{ section.id }}" > {% render 'icon-caret' %} </button> </div> </div> {%- if show_mobile_slider -%} <div class="slider-buttons no-js-hidden"> <button type="button" class="slider-button slider-button--prev" name="previous" aria-label="{{ 'general.slider.previous_slide' | t }}" > {% render 'icon-caret' %} </button> <div class="slider-counter caption"> <span class="slider-counter--current">1</span> <span aria-hidden="true"> / </span> <span class="visually-hidden">{{ 'general.slider.of' | t }}</span> <span class="slider-counter--total">{{ section.blocks.size }}</span> </div> <button type="button" class="slider-button slider-button--next" name="next" aria-label="{{ 'general.slider.next_slide' | t }}" > {% render 'icon-caret' %} </button> </div> {%- endif -%} </slideshow-component> {% endcomment %} <div class="swiper mySwiper"> <ul class="swiper-wrapper" id="Slider-{{ section.id }}" role="list" > {%- liquid assign columns = section.blocks.size if columns > 3 assign columns = 3 endif -%} {%- for block in section.blocks -%} <li id="Slide-{{ section.id }}-{{ forloop.index }}" class="swiper-slide custom-slider-slide grid__item{% if block.settings.collection.featured_image == nil %} collection-list__item--no-media{% endif %}" {{ block.shopify_attributes }} > {%- assign placeholder_image_index = forloop.index0 | modulo: 4 | plus: 1 -%} {%- assign placeholder_image = 'collection-apparel-' | append: placeholder_image_index -%} {% render 'custom-card-collection', card_collection: block.settings.collection, card_collection_image: block.settings.card_collection_image, media_aspect_ratio: section.settings.image_ratio, columns: columns, placeholder_image: placeholder_image %} </li> {%- endfor -%} </ul> <div class="swiper-button-next"></div> <div class="swiper-button-prev"></div> <div class="swiper-pagination"></div> </div> {%- if section.settings.show_view_all and section.blocks.size < collections.size -%} <div class="center collection-list-view-all{% if show_mobile_slider %} small-hide medium-hide{% endif %}{% if settings.animations_reveal_on_scroll %} scroll-trigger animate--slide-in{% endif %}" {% if settings.animations_reveal_on_scroll %} data-cascade {% endif %} > <a href="{{ routes.collections_url }}" class="button" id="ViewAllButton-{{ section.id }}" aria-labelledby="ViewAllButton-{{ section.id }} SectionHeading-{{ section.id }}" > {{- 'sections.collection_list.view_all' | t -}} </a> </div> {%- endif -%} </div> </div> <!-- Swiper JS --> <script src="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js"></script> <script> var swiper = new Swiper(".mySwiper", { slidesPerView: 4, spaceBetween: 1, autoplay: { delay: 2500, disableOnInteraction: false, }, navigation: { nextEl: ".swiper-button-next", prevEl: ".swiper-button-prev", }, pagination: { el: ".swiper-pagination", clickable: true, }, }); </script> {% schema %} { "name": "Custom collection list", "tag": "section", "class": "section section-collection-list custom-collection-list", "max_blocks": 15, "disabled_on": { "groups": ["header", "footer"] }, "settings": [ { "type": "inline_richtext", "id": "title", "default": "Collections", "label": "t:sections.collection-list.settings.title.label" }, { "type": "select", "id": "heading_size", "options": [ { "value": "h2", "label": "t:sections.all.heading_size.options__1.label" }, { "value": "h1", "label": "t:sections.all.heading_size.options__2.label" }, { "value": "h0", "label": "t:sections.all.heading_size.options__3.label" } ], "default": "h1", "label": "t:sections.all.heading_size.label" }, { "type": "select", "id": "image_ratio", "options": [ { "value": "adapt", "label": "t:sections.collection-list.settings.image_ratio.options__1.label" }, { "value": "portrait", "label": "t:sections.collection-list.settings.image_ratio.options__2.label" }, { "value": "square", "label": "t:sections.collection-list.settings.image_ratio.options__3.label" } ], "default": "square", "label": "t:sections.collection-list.settings.image_ratio.label", "info": "t:sections.collection-list.settings.image_ratio.info" }, { "type": "range", "id": "columns_desktop", "min": 1, "max": 7, "step": 1, "default": 3, "label": "t:sections.collection-list.settings.columns_desktop.label" }, { "type": "color_scheme", "id": "color_scheme", "label": "t:sections.all.colors.label", "info": "t:sections.all.colors.has_cards_info", "default": "scheme-1" }, { "type": "checkbox", "id": "show_view_all", "default": false, "label": "t:sections.collection-list.settings.show_view_all.label" }, { "type": "header", "content": "t:sections.collection-list.settings.header_mobile.content" }, { "type": "select", "id": "columns_mobile", "options": [ { "value": "1", "label": "t:sections.collection-list.settings.columns_mobile.options__1.label" }, { "value": "2", "label": "t:sections.collection-list.settings.columns_mobile.options__2.label" } ], "default": "1", "label": "t:sections.collection-list.settings.columns_mobile.label" }, { "type": "checkbox", "id": "swipe_on_mobile", "default": false, "label": "t:sections.collection-list.settings.swipe_on_mobile.label" }, { "type": "header", "content": "t:sections.all.padding.section_padding_heading" }, { "type": "range", "id": "padding_top", "min": 0, "max": 100, "step": 4, "unit": "px", "label": "t:sections.all.padding.padding_top", "default": 36 }, { "type": "range", "id": "padding_bottom", "min": 0, "max": 100, "step": 4, "unit": "px", "label": "t:sections.all.padding.padding_bottom", "default": 36 } ], "blocks": [ { "type": "featured_collection", "name": "t:sections.collection-list.blocks.featured_collection.name", "settings": [ { "type": "collection", "id": "collection", "label": "t:sections.collection-list.blocks.featured_collection.settings.collection.label" }, { "type": "image_picker", "id": "card_collection_image", "label": "Image", "info": "Image sizes to 1080 x 1080 pixels" } ] } ], "presets": [ { "name": "Custom collection list", "blocks": [ { "type": "featured_collection" }, { "type": "featured_collection" }, { "type": "featured_collection" } ] } ] } {% endschema %} {% render "custom-collection-list-css", section_id:section.id %}
Hi,
To make your categories autoplay and loop every 2.5 seconds, you just need to tweak the Swiper settings a bit. Here’s how you can do it:
Enable Autoplay and Looping: Update the Swiper configuration to ensure the slider automatically loops through the categories and advances every 2.5 seconds.
Adjust the Swiper Initialization: You’ll need to modify the JavaScript initialization of your Swiper slider to include autoplay and loop like this:
<script>
var swiper = new Swiper(".custom-collection-listing", {
slidesPerView: 4, // Adjust the number of slides to show at once
spaceBetween: 1,
loop: true, // Makes the slider loop infinitely
autoplay: {
delay: 2500, // Autoplay interval set to 2.5 seconds
disableOnInteraction: false, // Keeps autoplay running even if the user interacts
},
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
},
pagination: {
el: ".swiper-pagination",
clickable: true,
},
});
</script>
Key Points:
loop: true: This ensures that the slider will loop continuously.
autoplay: { delay: 2500, disableOnInteraction: false }: This sets the autoplay delay to 2.5 seconds and makes sure autoplay doesn’t stop when the user interacts with the slider.
This will set your slider to smoothly autoplay and loop every 2.5 seconds. Let me know if you need any further adjustments!
Hi. I changed my code a bit. Can u pls help me again:
{{ 'section-collection-list.css' | asset_url | stylesheet_tag }}
{{ 'component-card.css' | asset_url | stylesheet_tag }}
{{ 'component-slider.css' | asset_url | stylesheet_tag }}
{%- style -%}
.section-{{ section.id }}-padding {
padding-top: {{ section.settings.padding_top | times: 0.75 | round: 0 }}px;
padding-bottom: {{ section.settings.padding_bottom | times: 0.75 | round: 0 }}px;
}
@media screen and (min-width: 750px) {
.section-{{ section.id }}-padding {
padding-top: {{ section.settings.padding_top }}px;
padding-bottom: {{ section.settings.padding_bottom }}px;
}
}
{%- endstyle -%}
{%- liquid
assign columns_mobile_int = section.settings.columns_mobile | plus: 0
assign show_mobile_slider = false
if section.settings.swipe_on_mobile and section.blocks.size > columns_mobile_int
assign show_mobile_slider = true
endif
-%}
<div class="color-{{ section.settings.color_scheme }} gradient grid--{{ section.settings.columns_desktop }}-col-desktop">
<div class="collection-list-wrapper isolate{% if show_mobile_slider %} page-width-desktop{% endif %}{% if section.settings.title == blank %} no-heading{% endif %}{% if section.settings.show_view_all == false or section.blocks.size > collections.size %} no-mobile-link{% endif %} section-{{ section.id }}-padding">
{%- unless section.settings.title == blank -%}
<div class="title-wrapper-with-link{% if show_mobile_slider %} title-wrapper--self-padded-tablet-down{% else %} title-wrapper--self-padded-mobile{% endif %} title-wrapper--no-top-margin">
<h2
id="SectionHeading-{{ section.id }}"
class="collection-list-title inline-richtext {{ section.settings.heading_size }}{% if settings.animations_reveal_on_scroll %} scroll-trigger animate--slide-in{% endif %}"
>
{{ section.settings.title }}
</h2>
{%- if section.settings.show_view_all and show_mobile_slider -%}
<a
href="{{ routes.collections_url }}"
id="ViewAll-{{ section.id }}"
class="link underlined-link large-up-hide{% if settings.animations_reveal_on_scroll %} scroll-trigger animate--slide-in{% endif %}"
aria-labelledby="ViewAll-{{ section.id }} SectionHeading-{{ section.id }}"
>
{{- 'sections.collection_list.view_all' | t -}}
</a>
{%- endif -%}
</div>
{%- endunless -%}
<slideshow-component class="slider-mobile-gutter slider-component-desktop {% if settings.animations_reveal_on_scroll %} scroll-trigger animate--slide-in{% endif %}">
<ul
class="slideshow slider slider--everywhere custom-collection-listing collection-list contains-card contains-card--collection{% if settings.card_style == 'standard' %} contains-card--standard{% endif %} grid grid--{{ section.settings.columns_desktop }}-col-desktop grid--{{ section.settings.columns_mobile }}-col-tablet-down{% if section.settings.swipe_on_mobile %} slider slider--tablet grid--peek{% endif %} collection-list--{{ section.blocks.size }}-items"
id="Slider-{{ section.id }}"
role="list"
>
{%- liquid
assign columns = section.blocks.size
if columns > 3
assign columns = 3
endif
-%}
{%- for block in section.blocks -%}
<li
id="Slide-{{ section.id }}-{{ forloop.index }}"
class=" slideshow__slide slider__slide grid__item{% if show_mobile_slider %} slider__slide{% endif %}{% if block.settings.collection.featured_image == nil %} collection-list__item--no-media{% endif %}{% if settings.animations_reveal_on_scroll %} scroll-trigger animate--slide-in{% endif %}"
{{ block.shopify_attributes }}
{% if settings.animations_reveal_on_scroll %}
data-cascade
style="--animation-order: {{ forloop.index }};"
{% endif %}
>
{%- assign placeholder_image_index = forloop.index0 | modulo: 4 | plus: 1 -%}
{%- assign placeholder_image = 'collection-apparel-' | append: placeholder_image_index -%}
{% render 'custom-card-collection',
card_collection: block.settings.collection,
card_collection_image: block.settings.card_collection_image,
media_aspect_ratio: section.settings.image_ratio,
columns: columns,
placeholder_image: placeholder_image
%}
</li>
{%- endfor -%}
</ul>
<div class="slider-buttons no-js-hidden">
{% comment %}
<div class="slider-counter caption">
<span class="slider-counter--current">1</span>
<span aria-hidden="true"> / </span>
<span class="visually-hidden">{{ 'general.slider.of' | t }}</span>
<span class="slider-counter--total">{{ products_to_display }}</span>
</div>
{% endcomment %}
<div class="slider-button-button">
<button
type="button"
class="slider-button slider-button--prev"
name="previous"
aria-label="{{ 'sections.slideshow.previous_slideshow' | t }}"
aria-controls="Slider-{{ section.id }}"
>
{% render 'icon-caret' %}
</button>
<button
type="button"
class="slider-button slider-button--next"
name="next"
aria-label="{{ 'sections.slideshow.next_slideshow' | t }}"
aria-controls="Slider-{{ section.id }}"
>
{% render 'icon-caret' %}
</button>
</div>
</div>
{%- if show_mobile_slider -%}
<div class="slider-buttons no-js-hidden">
<button
type="button"
class="slider-button slider-button--prev"
name="previous"
aria-label="{{ 'general.slider.previous_slide' | t }}"
>
{% render 'icon-caret' %}
</button>
<div class="slider-counter caption">
<span class="slider-counter--current">1</span>
<span aria-hidden="true"> / </span>
<span class="visually-hidden">{{ 'general.slider.of' | t }}</span>
<span class="slider-counter--total">{{ section.blocks.size }}</span>
</div>
<button
type="button"
class="slider-button slider-button--next"
name="next"
aria-label="{{ 'general.slider.next_slide' | t }}"
>
{% render 'icon-caret' %}
</button>
</div>
{%- endif -%}
</slideshow-component>
{%- if section.settings.show_view_all and section.blocks.size < collections.size -%}
<div
class="center collection-list-view-all{% if show_mobile_slider %} small-hide medium-hide{% endif %}{% if settings.animations_reveal_on_scroll %} scroll-trigger animate--slide-in{% endif %}"
{% if settings.animations_reveal_on_scroll %}
data-cascade
{% endif %}
>
<a
href="{{ routes.collections_url }}"
class="button"
id="ViewAllButton-{{ section.id }}"
aria-labelledby="ViewAllButton-{{ section.id }} SectionHeading-{{ section.id }}"
>
{{- 'sections.collection_list.view_all' | t -}}
</a>
</div>
{%- endif -%}
</div>
</div>
{% schema %}
{
"name": "Custom collection list",
"tag": "section",
"class": "section section-collection-list custom-collection-list",
"max_blocks": 15,
"disabled_on": {
"groups": ["header", "footer"]
},
"settings": [
{
"type": "inline_richtext",
"id": "title",
"default": "Collections",
"label": "t:sections.collection-list.settings.title.label"
},
{
"type": "select",
"id": "heading_size",
"options": [
{
"value": "h2",
"label": "t:sections.all.heading_size.options__1.label"
},
{
"value": "h1",
"label": "t:sections.all.heading_size.options__2.label"
},
{
"value": "h0",
"label": "t:sections.all.heading_size.options__3.label"
}
],
"default": "h1",
"label": "t:sections.all.heading_size.label"
},
{
"type": "select",
"id": "image_ratio",
"options": [
{
"value": "adapt",
"label": "t:sections.collection-list.settings.image_ratio.options__1.label"
},
{
"value": "portrait",
"label": "t:sections.collection-list.settings.image_ratio.options__2.label"
},
{
"value": "square",
"label": "t:sections.collection-list.settings.image_ratio.options__3.label"
}
],
"default": "square",
"label": "t:sections.collection-list.settings.image_ratio.label",
"info": "t:sections.collection-list.settings.image_ratio.info"
},
{
"type": "range",
"id": "columns_desktop",
"min": 1,
"max": 7,
"step": 1,
"default": 3,
"label": "t:sections.collection-list.settings.columns_desktop.label"
},
{
"type": "color_scheme",
"id": "color_scheme",
"label": "t:sections.all.colors.label",
"info": "t:sections.all.colors.has_cards_info",
"default": "scheme-1"
},
{
"type": "checkbox",
"id": "show_view_all",
"default": false,
"label": "t:sections.collection-list.settings.show_view_all.label"
},
{
"type": "header",
"content": "t:sections.collection-list.settings.header_mobile.content"
},
{
"type": "select",
"id": "columns_mobile",
"options": [
{
"value": "1",
"label": "t:sections.collection-list.settings.columns_mobile.options__1.label"
},
{
"value": "2",
"label": "t:sections.collection-list.settings.columns_mobile.options__2.label"
}
],
"default": "1",
"label": "t:sections.collection-list.settings.columns_mobile.label"
},
{
"type": "checkbox",
"id": "swipe_on_mobile",
"default": false,
"label": "t:sections.collection-list.settings.swipe_on_mobile.label"
},
{
"type": "header",
"content": "t:sections.all.padding.section_padding_heading"
},
{
"type": "range",
"id": "padding_top",
"min": 0,
"max": 100,
"step": 4,
"unit": "px",
"label": "t:sections.all.padding.padding_top",
"default": 36
},
{
"type": "range",
"id": "padding_bottom",
"min": 0,
"max": 100,
"step": 4,
"unit": "px",
"label": "t:sections.all.padding.padding_bottom",
"default": 36
}
],
"blocks": [
{
"type": "featured_collection",
"name": "t:sections.collection-list.blocks.featured_collection.name",
"settings": [
{
"type": "collection",
"id": "collection",
"label": "t:sections.collection-list.blocks.featured_collection.settings.collection.label"
},
{
"type": "image_picker",
"id": "card_collection_image",
"label": "Image",
"info": "Image sizes to 1080 x 1080 pixels"
}
]
}
],
"presets": [
{
"name": "Custom collection list",
"blocks": [
{
"type": "featured_collection"
},
{
"type": "featured_collection"
},
{
"type": "featured_collection"
}
]
}
]
}
{% endschema %}
{% render "custom-collection-list-css", section_id:section.id %}
Hi,
To enable the loop and autoplay functionality for categories every 2.5 seconds, you need to add JavaScript to manage the slider's behavior. Here’s how you can achieve this:
Add the following script at the bottom of your section or within your theme’s theme.js or custom.js file:
<script>
document.addEventListener('DOMContentLoaded', function () {
const slider = document.querySelector('#Slider-{{ section.id }}');
if (!slider) return;
let currentIndex = 0;
const slides = slider.querySelectorAll('.slider__slide');
const totalSlides = slides.length;
const interval = 2500; // 2.5 seconds
function showSlide(index) {
slides.forEach((slide, i) => {
slide.style.display = i === index ? 'block' : 'none';
});
}
function autoplaySlider() {
currentIndex = (currentIndex + 1) % totalSlides;
showSlide(currentIndex);
}
// Initialize slider
showSlide(currentIndex);
// Start autoplay
setInterval(autoplaySlider, interval);
});
</script>
Umm... Unfortunately this didn't work. Can i give you staff access to my ws?
Hi, I will be happy to take a look at the website. I have sent you a message in the DM.
Hey Community! As we jump into 2025, we want to give a big shout-out to all of you wh...
By JasonH Jan 7, 2025Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024