Multiple dates
WordPress Event Management, Calendars & Registration › Forums › General Question › Multiple dates
This topic contains 7 replies, has 2 voices, and was last updated by Stephen Harris 11 years ago.
-
AuthorPosts
-
February 19, 2014 at 5:25 pm #9659
When an event occurs on a number of dates (not a fixed period), how do I get the dates into a template tag, listing the first date, or a series date isn’t really appropriate
Barry Meadows
February 19, 2014 at 7:38 pm #9660Hi Barry,
There isn’t a tag for listing all dates of an event, but you could use the following snippet to add a
%my_event_dates%
tag which lists all the dates of the event:add_filter( 'eventorganiser_email_template_tags', 'my_dates_email_tag', 10, 3 ); function my_dates_email_tag( $parsed_message, $booking_id, $original_message ){ //$parsed_message Email body with tags parsed //$booking_id The booking ID //$original_message Email body without tags parsed $event_id = eo_get_booking_meta( $booking_id, 'event_id' ); $occurrences = eo_get_the_occurrences_of( $event_id ); $formatted_dates = array(); if( $occurrences ){ foreach( $occurrences as $occurrence) { $formatted_dates[] = eo_format_datetime( $occurrence['start'] , 'jS F' ); } } $dates_list = implode( ', ', $formatted_dates ); $parsed_message = str_replace( '%my_event_dates%', $dates_list, $parsed_message ); return $parsed_message; }
Stephen Harris
February 20, 2014 at 12:10 pm #9669This looks like what I would like, but not just on the emails, on everywhere the dates are listed such as the template with eo_events – where do I add the hook to achieve this?
Barry Meadows
February 20, 2014 at 6:43 pm #9673That above snippet can be added to a utility plug-in or your theme’s functions.php (basically it can go in a plug-in/theme, but you should avoid putting it in something which you will ‘update’ because then you’ll loose your changes).
Regarding
[eo_events]
, I’m not sure what you mean. Unless you specifically tell it to ‘group occurrences’ (group_events_by=series
) it will display each date individually.Stephen Harris
February 21, 2014 at 8:35 am #9676Sorry for my poorly worded questin, I know to put the snippet into my themes function.php file
What I meant was how can I use the tag in [eo-events] and elsewhereI need to group events in [eo-events] otherwise a daily event takes over the list
So i need a way in the list to show all the dates:
– for a single occurance then one date
– for an event on several specific days the list of days
– for an event over a period of time: start and end datesI hope I’ve worded the question better now!
Barry Meadows
February 24, 2014 at 10:02 am #9701Ah, I see. It’s not as straightforward to add tags for the event list widget, but you can copy the appropriate template in to your theme and edit it instead of using the tags – this seems like a situation when this would be best. The template for the shortcode is
shortcode-event-list.php
(you can find it in the templates folder in Event Organiser).You could then using the following to display the event date(s) according to the three cases you mentioned:
//Format date according to whether the event is all day or not $format = eo_is_all_day() ? get_option( 'date_format' ) : get_option( 'date_format' ) . ' ' . get_option( 'time_format' ) ; if( !eo_reoccurs() && ( eo_get_the_start( 'Y-m-d' ) !== eo_get_the_end( 'Y-m-d' ) ) ){ //Event does not recur and it is a 'long' event: display start and end time echo eo_get_the_start( $format ) . ' – ' . eo_get_the_end( $format ); }elseif( !eo_reoccurs() ){ //Event does not recur but it not is a 'long' event: display start echo eo_get_the_start( $format ); }else{ //Event recurs: display list $event_id = eo_get_booking_meta( $booking_id, 'event_id' ); $occurrences = eo_get_the_occurrences_of( $event_id ); $formatted_dates = array(); if( $occurrences ){ foreach( $occurrences as $occurrence) { $formatted_dates[] = eo_format_datetime( $occurrence['start'] , 'jS F' ); } } echo implode( ', ', $formatted_dates ); }
(I wasn’t quite sure if “event on several specific days the list of days” meant ‘custom’ recurring pattern or “event over a period of time” meant a ‘long’ event (events where each occurrence passes over two or more days). But in case you want to differentiate between different types of recurring pattern:
$event_schedule = eo_get_event_schedule(); //$event_schedule['schedule'] is one of once, custom, daily, weekly, monthly or yearly
Stephen Harris
February 24, 2014 at 12:55 pm #9703That’s excellent, thank for your patience
I’ve got that working on the standard short-code without a template, but can’t get it to flow into the template, do I need to somehow edit the template?Barry Meadows
February 28, 2014 at 4:26 pm #9795Hi Barry,
Not sure what you mean. You mentioned you wanted to display the date(s) according to whether the event was recurring/long etc. Conditional statements aren’t supported in the shortcode tags, so you need to edit the template instead.
But the plug-in will ignore the template if you use the shortcode tags so you’d need to use
[eo_events]
as opposed to[eo_events]....[/eo_events]
.Stephen Harris
-
AuthorPosts