-
I have a collection of entries called "Programs" and I have a field that can show related "Testimonials" (another collection). For some reason the users want to have an active date range for a testimonial if applicable, so that it only appears within those dates. So in my Programs antlers template, I need to get all the related testimonials where todays date is between the active date, and I also need to know the number of matches. The only way I've been able to filter this data correctly is the following:
The only problem is I also need to know how many of these filtered results there are. The reason is because if there is only one match, I just display one, otherwise I need to generate a carousel to scroll between them. I can check the count of related_testmimonials with {{ if related_testimonials | count > 1 }} but that's before filtering. How can I do this in antlers? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Make a custom modifier that does that filtering, then Antlers will return a |
Beta Was this translation helpful? Give feedback.
Make a custom modifier that does that filtering, then Antlers will return a
{{ total_results }}
variable, or something like that. Do a{{ dump }}
inside the loop to see what vars are available.