Shopify themes, liquid, logos, and UX
Bonjour à tous,
Je rencontre une difficulté avec un carrousel. Le thème est craft. Je tente de faire un carousel/slider qui soit mixte avec des articles de blog et/ou des produits. Mais j'ai des erreurs qui m'échappent. Une bonne âme pourrait-elle se pencher sur mon "cas"
{
"name": "t:settings_schema.carousel-section.name",
"settings": [
{
"type": "text",
"label": "Titre",
"id": "title"
},
{
"type": "textarea",
"label": "Description",
"id": "description"
},
{
"type": "list",
"label": "Carousel Items",
"id": "carousel-item",
"itemType": "group",
"settings": [
{
"type": "text",
"label": "Titre",
"id": "item_title"
},
{
"type": "textarea",
"label": "Sous-titre",
"id": "item_subtitle"
},
{
"type": "textarea",
"label": "Texte",
"id": "item_text"
},
{
"type": "radio",
"label": "Type de contenu",
"id": "item_content_type",
"options": [
{"value": "product", "label": "Produit"},
{"value": "blog", "label": "Article de blog"}
]
},
{
"type": "product",
"label": "Sélectionnez le produit",
"id": "selected_product",
"showIf": {
"item_content_type": ["product"]
}
},
{
"type": "article",
"label": "Sélectionnez l'article de blog",
"id": "selected_blog_article",
"showIf": {
"item_content_type": ["blog"]
}
}
]
}
]
}
et le liquid
{%- assign max_items = 6 -%}
<div class="carousel-section">
{%- for block in section.blocks -%}
{%- if block.type == 'carousel-item' -%}
{%- assign product_or_blog = block.settings.product_or_blog -%}
{%- if forloop.index <= max_items -%}
<div class="carousel-item">
<h3>{{ block.settings.title }}</h3>
<p>{{ block.settings.subtitle }}</p>
<p>{{ block.settings.text }}</p>
{%- if product_or_blog == 'product' -%}
{%- assign product = block.settings.selected_product -%}
<img src="{{ product.images[0].url | img_url: 'large' }}" alt="{{ product.title }}">
<p>Prix: {{ product.price | money }}</p>
<a href="{{ product.url }}" class="btn">Voir le produit</a>
{%- else -%}
{%- assign blog_article = block.settings.selected_blog_article -%}
<img src="{{ blog_article.image.src | img_url: 'large' }}" alt="{{ blog_article.title }}">
<a href="{{ blog_article.url }}" class="btn">Lire l'article</a>
{%- endif -%}
</div>
{%- endif -%}
{%- endif -%}
{%- endfor -%}
</div>
Merci à tous !
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