Support

Home Forums Event Espresso Premium after update, the weekday doesn't show up

after update, the weekday doesn't show up

Posted: August 21, 2015 at 8:08 am

Viewing 8 reply threads


Oguzhan Altun

August 21, 2015 at 8:08 am

Hello,

After the recent EE4 update, the weekday column of the EE4 table stopped working:

http://www.genevaphotoclub.com/dates-prices/

Could you check what’s going on?

Here is the code in the event template php file:

<?php
// Options
$date_format		= get_option( 'date_format' );
$time_format		= get_option( 'time_format' );
// Load Venue View Helper
EE_Registry::instance()->load_helper('Venue_View');
//Defaults
$reg_button_text		= !isset($reg_button_text) ? __('Register', 'event_espresso') : $reg_button_text;
$alt_button_text		= !isset($alt_button_text) ? __('View Details', 'event_espresso') : $alt_button_text;//For alternate registration pages
$sold_out_button_text	= !isset($sold_out_button_text) ? __('Sold Out', 'event_espresso') : $sold_out_button_text;//For sold out events

if ( have_posts() ) :
	// allow other stuff
	do_action( 'AHEE__espresso_events_table_template_template__before_loop' );
	?>
	
	<?php if ($category_filter != 'false'){ ?>
	<p class="category-filter">
		<label><?php echo __('Category Filter', 'event_espresso'); ?></label>
		<select class="" id="ee_filter_cat">
		<option class="ee_filter_show_all"><?php echo __('Show All', 'event_espresso'); ?></option>
		<?php
		$taxonomy = array('espresso_event_categories');
		$args = array('orderby'=>'name','hide_empty'=>true);
		$ee_terms = get_terms($taxonomy, $args);

		foreach($ee_terms as $term){
			echo '<option class="' . $term->slug . '">'. $term->name . '</option>';
		}
	    ?>
		</select>
	</p>
	<?php } ?>
	
	<?php if ($footable != 'false' && $table_search != 'false'){ ?>
	<p>
        <?php echo __('Search:', 'event_espresso'); ?> <input id="filter" type="text"/>
    </p>
    <?php } ?>

	<table id="ee_filter_table" class="espresso-table footable table" data-page-size="<?php echo $table_pages; ?>" data-filter="#filter">
	<thead class="espresso-table-header-row">
		<tr>
    			<th class="th-group"><?php _e('Date','event_espresso'); ?></th>
    			<th class="th-group"><?php _e('Day','event_espresso'); ?></th>
    			<th class="th-group"><?php _e('Time','event_espresso'); ?></th>
    			<th class="th-group"><?php _e('Course','event_espresso'); ?></th>
    			<th class="th-group"><?php _e('Price','event_espresso'); ?></th>
			<th class="th-group" data-sort-ignore="true"></th>
		</tr>
	</thead>
	<?php if ($footable != 'false' && $table_paging != 'false'){ ?>
	<tfoot>
		<tr>
			<td colspan="4">
				<div class="pagination pagination-centered"></div>
			</td>
		</tr>
	</tfoot>
	<?php } ?>
	<tbody>

	<?php
	// Start the Loop.
	while ( have_posts() ) : the_post();
		// Include the post TYPE-specific template for the content.
		global $post;

		//Debug
		//d( $post );
		
		//Get the category for this event
		$event = EEH_Event_View::get_event();
		if ( $event instanceof EE_Event ) {
			if ( $event_categories = get_the_terms( $event->ID(), 'espresso_event_categories' )) {
				// loop thru terms and create links
				$category_slugs = '';
				foreach ( $event_categories as $term ) {
					$category_slugs[] = $term->slug;
				}
				$category_slugs = implode(' ', $category_slugs);
			} else {
				// event has no terms
				$category_slugs = '';
			}

		}
		//Create the event link
		$external_url 		= $post->EE_Event->external_url();
		$button_text		= !empty($external_url) ? $alt_button_text : $reg_button_text;
		$registration_url 	= !empty($external_url) ? $post->EE_Event->external_url() : $post->EE_Event->get_permalink();
		
		//Create the register now button
		$live_button 		= '<a class="register-button" id="a_register_link-'.$post->ID.'" href="'.$registration_url.'">'.$button_text.'</a>';

		if ( $event->is_sold_out() || $event->is_sold_out(TRUE ) ) {
			$live_button	= '<a id="a_register_link-'.$post->ID.'" class="soldout-button" href="'.$registration_url.'">'.$sold_out_button_text.'</a>';
		}
		

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

        foreach ( $datetimes as $datetime ) {
            $startdat = $datetime->start_date();
        }

		 // grab array of EE_Ticket objects for event
		$tickets = espresso_event_tickets_available( $post->ID, FALSE, FALSE );
		// grab first ticket from array
		$ticket = array_shift( $tickets );
		$ticket_price = $ticket instanceof EE_Ticket ? sprintf("%0.2f",$ticket->ticket_price()) . '<span class="currency-code"> (CHF)</span>' : '';
		$ticket_price_data_value = $ticket instanceof EE_Ticket ? $ticket->price() : '';
		$tickets_price_free_check = $ticket_price_data_value == 0 ? __('Free','event_espresso') : $ticket_price;

 		 // OA Add so that it doesn't show free for full events
 		 $tickets_price_free_check = (string)$ticket_price_data_value == '' ? __('Sold Out','event_espresso') : $tickets_price_free_check;
 		 
 		 // grab primary datetime for event
 		 $first_datetime = espresso_event_date_obj( $post->ID );
 		 $tickets_left = $first_datetime instanceof EE_Datetime ? $first_datetime->tickets_remaining() :   0;
 		 $tickets_left = $tickets_left === INF ? __('unlimited','event_espresso') : $tickets_left;

		?>
		<tr class="espresso-table-row <?php echo $category_slugs; ?>">
			<td class="start_date event-<?php echo $post->ID; ?>" data-value="<?php echo strtotime( $startdat ); ?>"><?php echo $startdat; ?></td>
			<td class="day_of_week event-<?php echo $post->ID; ?>"><?php echo espresso_event_date_range( 'l', ' ', ' ', ' ', $event->ID() ); ?></td>
			<td class="day_of_week event-<?php echo $post->ID; ?>"><?php echo espresso_event_date_range( 'G:i', ' ', ' ', ' ', $event->ID() ); ?></td>
			<td class="event_title event-<?php echo $post->ID; ?>"><?php echo $post->post_title; ?></td>
			<td style="text-align:center" class="starting_from_pricing event-<?php echo $post->ID; ?>"><?php echo $tickets_price_free_check; ?></td>
			<td style="text-align:center" class="td-group reg-col" nowrap="nowrap"><?php echo $live_button; ?></td>
		
		</tr>
		<?php

	endwhile;
	echo '</table>';
	// allow moar other stuff
	do_action( 'AHEE__espresso_events_table_template_template__after_loop' );

else :
	// If no content, include the "No posts found" template.
	espresso_get_template_part( 'content', 'none' );

endif;


Josh

  • Support Staff

August 21, 2015 at 9:20 am

Hi there,

It looks like you’re either running an old version of Events Table Template add-on, or your custom template is based off an older version. You’ll need to update to the current version and update your custom template so it’s compatible with the new datetime code in 4.8. You can copy the code from the updated base template and merge it into your custom template.


Oguzhan Altun

August 21, 2015 at 10:32 am

hi there,

i made loads of changes on that template long time ago with the support of EE4 team, so really no clue how to re-create that now. Would you maybe check which specific area is the problem?


Tony

  • Support Staff

August 21, 2015 at 1:32 pm

The day of the week doesn’t work because of how espresso_event_date_range() is being used.

These are the expected parameters for that function:

espresso_event_date_range( 
$date_format = '', 
$time_format = '', 
$single_date_format = '', 
$single_time_format = '', 
$EVT_ID = FALSE, 
$echo = TRUE )

The call you are using now is setting all of the date and time formats to an empty space apart from the first. Which means $single_date_format is being set to an space and breaking the output.

Change this:

espresso_event_date_range( 'l', ' ', ' ', ' ', $event->ID() );

to this:

espresso_event_date_range( 'l', ' ', 'l', ' ', $event->ID() );

Not that function will only work as expected if you have a single datetime and the start and end date is set the same.

espresso_event_date_range() is not really the right function to use for this, you should pull the datetimes, then find use $datetime->start_date({date_format_to_use})

  • This reply was modified 9 years, 3 months ago by Tony. Reason: fixed function call spaces


Josh

  • Support Staff

August 21, 2015 at 1:45 pm

Hi there,

I went through the template and applied Tony’s suggested fix to the one valid use of the date_range tag, and fixed a few other things. You can review the changes here:

https://gist.github.com/joshfeck/fb2e40b80294d3f12144

Hope that helps!


Oguzhan Altun

August 21, 2015 at 4:24 pm

perfect, it works now:) Thanks a lot, very much appreciated:)


Oguzhan Altun

September 4, 2015 at 5:35 pm

Hello,
Sorry to bring this up again but something else doesn’t work as before. In the “Time” column, I used to have the start and finish time (e.g.: 9:00 – 13:00) – now it only shows the start time. How could I add the end time back?
http://www.genevaphotoclub.com/dates-prices/


Dean

September 7, 2015 at 5:02 am

Hi,

Below where it says

$starttime = date_i18n( 'G:i', strtotime( $datetime->start_time('H:i:s') ) );

add

$endtime = date_i18n( 'G:i', strtotime( $datetime->end_time('H:i:s') ) );

then where it says

<td class="time event-<?php echo $post->ID; ?>"><?php echo $starttime ; ?></td>

change it to

<td class="time event-<?php echo $post->ID; ?>"><?php echo $starttime ; ?> - <?php echo $endtime ; ?></td>


Oguzhan Altun

September 8, 2015 at 11:53 am

yes, this worked perfectly. Thanks a lot! 🙂

Viewing 8 reply threads

The support post ‘after update, the weekday doesn't show up’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso