unionco / calendarize

Calendar Field Type for CraftCMS
MIT License
18 stars 13 forks source link

Feature Request: "unique" attribute for calendarize.upcoming queries #17

Closed langlers closed 5 years ago

langlers commented 5 years ago

First of all, thanks for a great plugin. I love the upcoming query option, but in a few cases, I need to get a list of unique upcoming events, e.g., with only the next upcoming instance of a repeating event---so that each event entry is listed once in the result set. I don't see a "calendarize" way of doing that. Am I missing something obvious or could this be a candidate for a new feature?

fvaldes33 commented 5 years ago

@langlers - I could propose adding a unique flag to the three calendarize methods. This would limit the occurrence to 1.

{% set unique = true %}

{% set entries = craft.calendarize.upcoming({ section: ['events'] }, 'asc|desc', unique) %}
{% set entries = craft.calendarize.after('2019-01-04', { section: ['events'] }, 'asc|desc', unique) %}
{% set entries = craft.calendarize.between('2019-01-01', '2019-01-31', { section: ['events'] }, 'asc|desc', unique) %}
langlers commented 5 years ago

@fvaldes33 Sounds great. I think this will be very useful in, e.g., upcoming event widgets. Thanks for the quick response.

fvaldes33 commented 5 years ago

Added in latest commit.