0

I have the following problem. I have a FOR loop and couple of IF statements like this:

{% for option in group %} {% if option.type == 'palette' %} {% for option_value in option.product_option_value %} {% if option_value.image %} <div>I am here</div> {% endif %} {% endfor %} {% endif %} {% endfor %} 

I just want to check/create one IF statements showing whether or not there is option_value.image anywhere (showing at least once).

Thanks in advance

0

1 Answer 1

0

You can set a variable to 0 and set it to 1 inside the if statement then you can check if 1 or 0

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks, that worked!
But I still think there should be a shorter way of doing it
No there is not, you can't break out of a loop inside twig. You would need to add a custom function / filter to achieve a "shorter" solution.
Is there a way I can break out of the loop after the first result is hit?
Read my previous comment?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.