Answer the question
In order to leave comments, you need to log in
How to make a condition in twig less than or equal?
Good afternoon, tell me how to make a condition in twig
In the template, we have the output of product categories in which it is located (some have more than 1, and some have 1), I need products with 1 or less category not to display this cat_list block
{% if cat_list %}
<div class="uni-module product-cat_list">
<div class="category-list row row-flex">
{% for cat in cat_list %}
<div>
<a href="{{ cat.href }}" class="category-list__item image-after">
{% if cat.image_src %}
<img src="{{ cat.image_src }}" alt="{{ cat.name }}" title="{{ cat.name }}" class="category-list__img img-responsive" />
{% endif %}
{{ cat.name }}
</a>
</div>
{% endfor %}
</div>
</div>
<script>
$('.product-cat_list').uniModules({
type:'{{type_view is defined ? type_view : 'carousel'}}',
loop: {{cat_list|length > 4 ? 'true' : 'false'}}
});
</script>
{% endif %}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question