New: Learn Statamic on Laracasts!

We've retired the forum in favor of GitHub Discussions.

New conversations can be started on GitHub. Existing conversations will remain for a while longer.

Head over to GitHub →

Match Conditions Twice, Show Entry Once

mar627 June 17, 2019 by mar627

How can I show this entry once, even if it meets the if condition twice? The goal is to show events that are in the month, by comparing this month with dates within an array. The problem is if both date values are a match, then the title is displayed twice.

Collection Entry:

title: 'My Cool Event'
    date_entry: 'Wed Jun 12 2019'
    date_entry: 'Tue Jun 11 2019'

Collection and If Tags:

{{ collection:events }}

{{ entry_date }}
{{ if date_entry|format:M == today|format:M }}

<h5>{{ title }}<br></h5>

{{ /if }}
{{ /entry_date }}

{{ /collection:events }}

At present, this outputs the title twice - as both event dates are within the current month.

Ideas - as the collection tag iterates, check if the current item title matches the previous, silence if true. - something with the increment tag?

Thanks <3

Answered by mar627!
>>>>>>> Answered <<<<<<<
2 Replies