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 -%}
{%- for block in section.blocks -%}
{%- if block.type == 'carousel-item' -%}
{%- assign product_or_blog = block.settings.product_or_blog -%}
{%- if forloop.index <= max_items -%}
### {{ block.settings.title }}
{{ block.settings.subtitle }}
{{ block.settings.text }}
{%- if product_or_blog == 'product' -%}
{%- assign product = block.settings.selected_product -%}
Prix: {{ product.price | money }}
Voir le produit
{%- else -%}
{%- assign blog_article = block.settings.selected_blog_article -%}
Lire l'article
{%- endif -%}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
Merci à tous !