I have the following twig code:
{% for likeditem in user.getItemLikes() %}
//iterate over each liked items here
{% endfor %}
however I wanted to iterate only the first 3 items of user.getItemLikes()
how do I do so?
Looks like you can use the slice filter for what you are trying to do:
{% for likeditem in user.getItemLikes()|slice(0,3) %}
//iterate over each liked items here
{% endfor %}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With