s1lentium / craft-recurring-dates
This is a plugin for the Craft CMS to add recurring dates functionality
Installs: 29
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 6
Type:craft-plugin
Requires
- simshaun/recurr: ^2.2.3
This package is auto-updated.
Last update: 2024-10-18 19:06:31 UTC
README
I could still use help testing and bug fixing. If you find any issues put them in the Github issues. Thanks
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.
###Installation
- Clone this project into
your_craft_dir/craft/plugins/recurringdate
- Install Composer from getcomposer.org
- Run
composer install
orphp composer.phar install
in therecurringdate
directory to install dependencies - Install the plugin through the Craft admin panel
###Usage
- Add a new Advanced Date Field type to one of your sections
- Output is either an array of dates and the entries associated with them or an array of the values used to set the date rule. Output depends on how you query the dates
- Multiple Dates Query can be used to automatically sort and filter corresponding dates. I built this with an event calendar in mind, that would need recurring dates.
####Example Output Usage - Multiple Dates Query
{% 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 %}
####Arguments for craft.recurringdate.dates
- Field Handle - Handle of your field in the Craft CP
Values in the options array - see above example for usage
limit
- limit the number of entries returnedorder
- 'ASC' or 'DESC' - defaults to 'ASC'group
- null, 'day', 'month', or 'year' - See Grouping Info Belowbefore
- null, or Date string accepted by PHP's strtotime functionafter
- null, or Date string accepted by PHP's strtotime functioncriteria
- ElementCriteriaModel returned by a craft entry queryexcludes
- if excluded dates should be respected - defaults to true
####Properties available for output for Multiple Dates Query
date
- Array containing all the date info for the recurring dateid
- Id of the date, used to query the correct date in a sequenceelementId
- Id of the Craft entry associated with this datestart
- 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 date
entry
- The entry associated with this date
####Info about using Group for Multiple Dates Query The Group query will return a different structure than a regular query. It's structure looks like this
array(
'grouped_date_string' = array(
array('date', 'entry'),
array('date', 'entry'),
...
),
'grouped_date_string2' = array(
array('date', 'entry'),
array('date', 'entry')
),
...
)
####Example Output Usage - Single Date Query using Date ID
{% 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") }}
####Properties available for output for Single Date Query
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.
####Example Output Usage - Single Entry
{% 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") }}
####Properties available for output for each Advanced Date Field - Single Entry
start_date
- Craft DateTime Object - Start date set for the eventstart_time
- Craft DateTime Object - Same as startdateend_date
- Craft DateTime Object - End date set for the event, can be null if not setend_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 ifends
is not 'after'until
- Craft DateTime Object - Date event goes until, undefined ifends
is not 'until'rrule
- RRULE string used to build the rule