Skip to content

Instantly share code, notes, and snippets.

@lorenzocaum
Last active February 10, 2017 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lorenzocaum/ac217033f12232404cce to your computer and use it in GitHub Desktop.
Save lorenzocaum/ac217033f12232404cce to your computer and use it in GitHub Desktop.
Edit the Events Table View Template Add-on for Event Espresso 4 to show all available starting date times

The steps below for making changes via custom templates are no longer recommended. You can use this shortcode:

[ESPRESSO_EVENTS_TABLE_TEMPLATE show_all_datetimes=TRUE]

See this page for more information: https://eventespresso.com/wiki/events-table-view-template-add-on/

This can be done by relocating one of the templates and making a change to some lines of code. This will ensure that your customization is not lost on a software update.

The support team at Event Espresso will never recommend you edit any core plugin or add-on files directly.

Here are the steps:

  1. Login to your WordPress root with your preferred SFTP or FTP client. Filezilla and Cyberduck are free options. On a Mac? Try Transmit

  2. Browse to this location:

/wp-content/plugins/eea-events-table-view-template/templates

You'll see two files there:

espresso-events-table-template-toggle.template.php

espresso-events-table-template.template.php

  1. Download a copy of the espresso-events-table-template.template.php file to your computer

  2. Now browse to this location:

/wp-content/uploads/espresso/templates

  1. Upload the the file that you downloaded earlier to the location above

  2. Open the espresso-events-table-template.template.php file for editing

At about line 99 you'll see this line of code:

		$datetimes = EEM_Datetime::instance()->get_datetimes_for_event_ordered_by_start_time( $post->ID, $show_expired, false, 1 );

		$datetime = end( $datetimes );
  1. Replace the line above with this:
		$datetimes = EEM_Datetime::instance()->get_datetimes_for_event_ordered_by_start_time( $post->ID, $show_expired, false );

		$datetime = end( $datetimes );
  1. At about line 112 you'll see this line of code:
			<td class="start_date event-<?php echo $post->ID; ?>" data-value="<?php echo $datetime->get_raw( 'DTT_EVT_start' ); ?>"><?php echo $startdate; ?></td>
  1. Replace it with this:
<td class="start_date event-<?php echo $post->ID; ?>" data-value="<?php echo $datetime->get_raw( 'DTT_EVT_start' ); ?>">
		<ul>
		<?php  
			foreach ( $datetimes as $datetime ) {
			echo '<li style="list-style-type:none;">'.$datetime->start_date_and_time().'</li>';
		} ?></ul></td>

Then save changes.

@lorenzocaum
Copy link
Author

Here is an alternative version that will show all datetimes along with an iCal button for each.

This can be done by relocating one of the templates and making a change to some lines of code. This will ensure that your customization is not lost on a software update. Here are the steps:

  1. Login to your WordPress root with your preferred SFTP or FTP client. Filezilla and Cyberduck are free options. On a Mac? Try Transmit

  2. Browse to this location:

/wp-content/plugins/eea-events-table-view-template/templates

You'll see two files there:

espresso-events-table-template-toggle.template.php

espresso-events-table-template.template.php

  1. Download a copy of those files above to your computer

  2. Now browse to this location:

/wp-content/uploads/espresso/templates

  1. Upload the two files that you downloaded earlier to the location above

  2. Open the espresso-events-table-template.template.php file for editing

At about line 8 add the following code snippet just above the "if ( have_posts() ) :)"

if ( ! function_exists( 'espresso_list_of_event_dates_table_template' )) {
    /**
     * espresso_list_of_event_dates
     * returns a unordered list of dates for an event
     *
     * @param int    $EVT_ID
     * @param string $date_format
     * @param string $time_format
     * @param bool   $echo
     * @param null   $show_expired
     * @param bool   $format
     * @param bool   $add_breaks
     * @param null   $limit
     * @return string
     */
    function espresso_list_of_event_dates_table_template( $EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL ) {
        $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' );
        $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' );
        $date_format = apply_filters( 'FHEE__espresso_list_of_event_dates__date_format', $date_format );
        $time_format = apply_filters( 'FHEE__espresso_list_of_event_dates__time_format', $time_format );
        EE_Registry::instance()->load_helper( 'Event_View' );
        $datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, $show_expired, FALSE, $limit );
        if ( ! $format ) {
            return apply_filters( 'FHEE__espresso_list_of_event_dates__datetimes', $datetimes );
        }
        //d( $datetimes );
        if ( is_array( $datetimes ) && ! empty( $datetimes )) {
            global $post;
            $html = $format ? '<ul id="ee-event-datetimes-ul-' . $post->ID . '" class="ee-event-datetimes-ul">' : '';
            foreach ( $datetimes as $datetime ) {
                if ( $datetime instanceof EE_Datetime ) {
                    $html .= '<li style="list-style-type:none;" id="ee-event-datetimes-li-' . $datetime->ID() . '" class="ee-event-datetimes-li">';
                    $datetime_name = $datetime->name();
                    $html .= ! empty( $datetime_name ) ? '<strong>' . $datetime_name . '</strong>' : '';
                    $html .= ! empty( $datetime_name )  && $add_breaks ? '<br />' : '';
                    $html .= '' . $datetime->date_range( $date_format ) . ' from ' . $datetime->time_range( $time_format );
                    $datetime_description = $datetime->description();
                    $html .= ! empty( $datetime_description )  && $add_breaks ? '<br />' : '';
                    $html .= ! empty( $datetime_description ) ? ' - ' . $datetime_description : '';
                    $html = apply_filters( 'FHEE__espresso_list_of_event_dates__datetime_html', $html, $datetime );
                    $html .= '</li>';
                }
            }
            $html .= $format ? '</ul>' : '';
        } else {
            $html = $format ?  '<p><span class="dashicons dashicons-marker pink-text"></span>' . __( 'There are no upcoming dates for this event.', 'event_espresso' ) . '</p><br/>' : '';
        }
        if ( $echo ) {
            echo $html;
            return '';
        }
        return $html;
    }
}
  1. At about line 162 you'll see this line of code:
<td class="start_date event-<?php echo $post->ID; ?>" data-value="<?php echo strtotime( $startdat ); ?>"><?php echo $startdat; ?></td>
  1. Replace it with this:
<td class="start_date event-<?php echo $post->ID; ?>" data-value="<?php echo strtotime( $startdat ); ?>"><?php echo espresso_list_of_event_dates_table_template(); ?></td>

Then save changes.

@lorenzocaum
Copy link
Author

Here is an alternative version that will show the first datetime without the time (e.g. December 10, 2016 instead of December 10, 2016 7:00am)

This can be done by relocating one of the templates and making a change to some lines of code. This will ensure that your customization is not lost on a software update. Here are the steps:

  1. Login to your WordPress root with your preferred SFTP or FTP client. Filezilla and Cyberduck are free options. On a Mac? Try Transmit

  2. Browse to this location:

/wp-content/plugins/eea-events-table-view-template/templates

You'll see two files there:

espresso-events-table-template-toggle.template.php

espresso-events-table-template.template.php

  1. Download a copy of the espresso-events-table-template.template.php file to your computer

  2. Now browse to this location:

/wp-content/uploads/espresso/templates

  1. Upload the the file that you downloaded earlier to the location above

  2. Open the espresso-events-table-template.template.php file for editing

At about line 106 you'll see this line of code:

        $startdate = date_i18n( $date_format . ' ' . $time_format, strtotime( $datetime->start_date_and_time('Y-m-d', 'H:i:s') ) );
  1. Replace the line above with this:
        $startdate = date_i18n( $date_format, strtotime( $datetime->start_date_and_time('Y-m-d', 'H:i:s') ) );

Then save changes.

@lorenzocaum
Copy link
Author

Here is an alternative version that will show a date range including the time (e.g. December 10, 2014 8:00am - January 10, 2015 5:00pm)

This can be done by relocating one of the templates and making a change to some lines of code. This will ensure that your customization is not lost on a software update. Here are the steps:

  1. Login to your WordPress root with your preferred SFTP or FTP client. Filezilla and Cyberduck are free options. On a Mac? Try Transmit

  2. Browse to this location:

/wp-content/plugins/eea-events-table-view-template/templates

You'll see two files there:

espresso-events-table-template-toggle.template.php

espresso-events-table-template.template.php

  1. Download a copy of the espresso-events-table-template.template.php file to your computer

  2. Now browse to this location:

/wp-content/uploads/espresso/templates

  1. Upload the the file that you downloaded earlier to the location above

  2. Open the espresso-events-table-template.template.php file for editing

At about line 162 you'll see this line of code:

            <td class="start_date event-<?php echo $post->ID; ?>" data-value="<?php echo $datetime->get_raw( 'DTT_EVT_start' ); ?>"><?php echo $startdate; ?></td>
  1. Replace the line above with this:
            <td class="start_date event-<?php echo $post->ID; ?>" data-value="<?php echo $datetime->get_raw( 'DTT_EVT_start' ); ?>"><?php echo espresso_event_date_range(); ?></td>

Then save changes.

@lorenzocaum
Copy link
Author

Here is an alternative version that will show a date range without the time (e.g. December 10, 2016 - January 10, 2016)

This can be done by relocating one of the templates and making a change to some lines of code. This will ensure that your customization is not lost on a software update. Here are the steps:

  1. Login to your WordPress root with your preferred SFTP or FTP client. Filezilla and Cyberduck are free options. On a Mac? Try Transmit

  2. Browse to this location:

/wp-content/plugins/eea-events-table-view-template/templates

You'll see two files there:

espresso-events-table-template-toggle.template.php

espresso-events-table-template.template.php

  1. Download a copy of the espresso-events-table-template.template.php file to your computer

  2. Now browse to this location:

/wp-content/uploads/espresso/templates

  1. Upload the the file that you downloaded earlier to the location above

  2. Open the espresso-events-table-template.template.php file for editing

At about line 112 you'll see this line of code:

            <td class="start_date event-<?php echo $post->ID; ?>" data-value="<?php echo $datetime->get_raw( 'DTT_EVT_start' ); ?>"><?php echo $startdate; ?></td>
  1. Replace the line above with this:
            <td class="start_date event-<?php echo $post->ID; ?>" data-value="<?php echo $datetime->get_raw( 'DTT_EVT_start' ); ?>"><?php echo espresso_event_date_range( 'F j, Y', ' ', 'F j, Y ', ' ', $event->ID() ); ?></td>

Then save changes.

@ambisyoso901
Copy link

Hi Sir,

Instead of Register link can we change it to add to cart directly?

is it possible?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment