dev-master
9999999-devThis is a plugin for the Craft CMS to add recurring dates functionality
MIT
The Requires
by Alisher Safarov
This is a plugin for the Craft CMS to add recurring dates functionality
This is a plugin for the Craft CMS to add recurring dates functionality. It adds a new field type called Advanced Date which has the recurring date functions. It stores the recurring dates and an rule in the data base and returns an array of dates to the twig templates. I'm using the Recurr library by simshaun to build and parse the rrule., (*1)
your_craft_dir/craft/plugins/recurringdate
composer install
or php composer.phar install
in the recurringdate
directory to install dependencies{% set query = craft.entries.section('events').relatedTo(craft.categories.slug('your-slug')) %} {% set events = craft.recurringdate.dates('yourFieldHandle', { 'limit': 3, 'before': '12/22/2014', 'after': 'now +1 months', 'criteria': query }) %} {% for event in events %} {{ event.date.start|date("n/j/Y") }}{{ event.date.end ? ' -- ' ~ event.date.end|date("n/j/Y") }}<br> {% endfor %}
craft.recurringdate.dates
Values in the options array - see above example for usage
* limit
- limit the number of entries returned
* order
- 'ASC' or 'DESC' - defaults to 'ASC'
* group
- null, 'day', 'month', or 'year' - See Grouping Info Below
* before
- null, or Date string accepted by PHP's strtotime function
* after
- null, or Date string accepted by PHP's strtotime function
* criteria
- ElementCriteriaModel returned by a craft entry query
* excludes
- if excluded dates should be respected - defaults to true, (*2)
date
- Array containing all the date info for the recurring date
id
- Id of the date, used to query the correct date in a sequenceelementId
- Id of the Craft entry associated with this date start
- A string containing the start dateend
- A string containing the end date, if setstart_time
- A string containing the start time, if setend_time
- A string containing the end time, if setallday
- If the date lasts all dayrepeats
- If the date repeatsrrule
- The RRULE string used to build the dateentry
- The entry associated with this dateThe Group query will return a different structure than a regular query. It's structure looks like this, (*3)
array( 'grouped_date_string' = array( array('date', 'entry'), array('date', 'entry'), ... ), 'grouped_date_string2' = array( array('date', 'entry'), array('date', 'entry') ), ... )
{% set row = craft.recurringdate.date(id) %} {% set date = row.date %} {% set entry = row.entry %} {{ entry.title }}<br> {{ date.start_date|date("n/j/Y H:i:s") }}{{ date.end_date is defined ? ' -- ' ~ date.end_date|date("n/j/Y H:i:s") }}
The Single Date Query will only return one array that contains the date
and the entry
of the row with the specified ID. The idea is that you would use the multiple date query to list the date's ID and then you can select which specific date you want to display based on that ID., (*4)
{% set date = entry.advanced_date_field_name %} {{ date.start_date|date("n/j/Y H:i:s") }}{{ date.end_date is defined ? ' -- ' ~ date.end_date|date("n/j/Y H:i:s") }}
start_date
- Craft DateTime Object - Start date set for the event start_time
- Craft DateTime Object - Same as startdateend_date
- Craft DateTime Object - End date set for the event, can be null if not set end_time
- Craft DateTime Object - Same as enddateallday
- Boolean - If the event is an allday eventrepeats
- Boolean - If the event repeatsfrequency
- String - Recurrence frequency, 'daily', 'weekly', 'monthly', 'yearly'interval
- Int - Recurrence Interval, integer from 1-31weekdays
- Array - days of the week that the event occurs, undefined if interval not weekly, 'SU', 'MO', 'TU', etc...repeat_by
- String - by day of week or day of month, undefined if interval not monthly, 'week', 'month'ends
- String - how the event ends, 'never', 'after', 'until'count
- Int - How many times this occurs, undefined if ends
is not 'after'until
- Craft DateTime Object - Date event goes until, undefined if ends
is not 'until'rrule
- RRULE string used to build the ruleThis is a plugin for the Craft CMS to add recurring dates functionality
MIT