If you are a developer, there are a few filters you can use to customize the output of the events in your newsletter. Some you can customize just for the manual ‘Generate Newsletter Formatted Events’ or for the automatic feed into Mailchimp, MailPoet or other email sending services.
Looking to create your own custom tag, ie. turning {my_tag} into some HTML? There’s a blog post on that.
ecn_pro_group_by_day_prefix and ecn_pro_group_by_day_suffix
Alter the start/end HTML tag for the “group by day” output. By default this is an h3 tag.
Example:
function custom_ecn_group_by_day_prefix( $output ) {
return ‘<h2 style=”margin-bottom:10px;”>’;
}
add_filter( ‘ecn_pro_group_by_day_prefix’, ‘custom_ecn_group_by_day_prefix’ );function custom_ecn_group_by_day_suffix( $output ) {
return ‘</h2>’;
}
add_filter( ‘ecn_pro_group_by_day_suffix’, ‘custom_ecn_group_by_day_suffix’ );
Similarly you can use the ecn_pro_group_by_month_prefix and ecn_pro_group_by_month_suffix for “group by month”.
ecn_format_output_from_event: $output, $event, $args, $previous_date
This filter is run before the main output of the event. Useful for prefixing HTML before the main event HTML is rendered, such as the beginning of a table row.
Arguments:
$output – current output of the event, which is likely blank at the beginning
$event – the ECNCalendarEvent object
$args – array arguments for the output. Includes:
- format for the event format,
- group_events (string: “day” “month” or blank),
- event_number which is the current number of this event in the loop through all events,
- events which is an array of all events, and
- is_rss which is true if this is the feed and false if manual generation
$previous_date – the date of the last event in the loop
Example
function before_event_output( $output, $event, $args, $previous_date ) {
if ( 1 == $args[‘event_number’] or $args[‘event_number’] / 2 == floor( $args[‘event_number’] / 2 ) ) {
// 2 columns, so if one of the even rows, pop in the table row HTML
$output = ‘<tr style=”…”>’ . $output;// If the first of 2 columns, add in the ‘first’ class
$extra_class = ‘first’;
} else {
$extra_class = ‘last’;
}// Begin the table cell HTML
$output = ‘<th class=”small-12 large-6 columns ‘ . $extra_class . ‘”
style=”…”
align=”left”>’ . $output;
return $output;
}
add_filter( ‘ecn_format_output_from_event’, ‘before_event_output’, 10, 4 );
ecn_output_format: $format, $event, $args, $previous_date
Used the customize or override the format for the event output, which is normally specified in the format box or in a saved template.
Example
function output_format( $format, $event, $args, $previous_date ) {
$format = ‘
<table style=”…”>
<tr style=”…”>
<th style=”…”
align=”left”>
<h5 class=”text-center”
style=”…”
align=”center”><a
href=”{link_url}”
style=”…”>{title} @ {location_name}</a></h5>
<center style=”width: 100%; min-width: 242px;”>{start_date} @ {start_time}
</center>
<center data-parsed=”” style=”…”><a
href=”{link_url}”
style=”…”><img
src=”{event_image_url}”
align=”center” class=”text-center”
style=”…”/></a>
</center>
<p class=”text-center”
style=”…”
align=”center”>{excerpt}</p>
</th>
</tr>
</table>
‘;
return $format;
}
add_filter( ‘ecn_output_format’, ‘output_format’, 10, 4 );
ecn_format_output_from_event_after: $output, $event, $args, $previous_date
Filter run after the output for an event has been generated.
function after_event_output( $output, $event, $args, $previous_date ) {
$output .= ‘</th>’;
if ( $args[‘event_number’] == count( $args[‘events’] ) or $args[‘event_number’] / 2 == floor( $args[‘event_number’] / 2 ) ) {
$output .= ‘</tr>’;
}
return $output;
}
add_filter( ‘ecn_format_output_from_event_after’, ‘after_event_output’, 10, 4 );
ecn_start_date_output: ECNCalendarEvent $event, $options
Filter for defining the output of the {start_date} merge tag.
function my_start_date_output( $output, $event, $options ) {
return date_i18n( ‘l F d, Y’, $event->get_start_date() );
}
add_filter( ‘ecn_start_date_output’, ‘my_start_date_output’, 10, 3 );