Support

Home Forums Event Espresso Premium ESPRESSO_EVENTS_TABLE_TEMPLATE issues

ESPRESSO_EVENTS_TABLE_TEMPLATE issues

Posted: October 3, 2017 at 10:04 pm

Viewing 16 reply threads


kellyjo

October 3, 2017 at 10:04 pm

Hey EE4 Team,

Getting right into detail: I’ve customized this code: ESPRESSO_EVENTS_TABLE_TEMPLATE

I had uploaded the file: /wp-content/uploads/espresso/templates/espresso-events-table-template.template.php (pretty much using this code [ https://gist.github.com/joshfeck/822763b36a371f7ec43e ] with modifications to “trim out the fat” per se.. in other words, I’m checking to see what the URL is and depending on that, to show all events, this month’s events only, or past events… so mainly just date modifications.)

I’ve been using the ESPRESSO_EVENTS_TABLE_TEMPLATE code for quite some time:

[ESPRESSO_EVENTS_TABLE_TEMPLATE show_expired=true show_all_datetimes=true sort=DESC table_paging=false]

This code would result in me being able to view ALL PAST EVENTS on a single page without the need for any pagination.

Up until recently, it is like any code within that espresso-events-table-template.template.php file is being ignored. I had it set to only show OLD events that were past and expired. However, it is showing some OLD events for up to about 10 days ago and NEW events and future events only.

I’ve attempted to compensate and even go back to pagination and it does work, but the per_page defaults to 10 no matter what number I put in, 20, 25, 50, or 100… all resulting in about 90 pages of pagination and its just an awful mess.

Is there any way I can change this number to per_page=100? And show only past events? OR how can I ensure that espresso-events-table-template.template.php is being recognized?

Thanks for your help.


kellyjo

October 3, 2017 at 10:29 pm

Here is a sample of what I’m talking about with the Pagination: https://mypost.io/post/kj-pagination

It is just a bit too much when I can only view 10 events per page.


Tony

  • Support Staff

October 4, 2017 at 3:57 am

Hi there,

This code would result in me being able to view ALL PAST EVENTS on a single page without the need for any pagination.
Up until recently, it is like any code within that espresso-events-table-template.template.php file is being ignored. I had it set to only show OLD events that were past and expired. However, it is showing some OLD events for up to about 10 days ago and NEW events and future events only.

The shortcode above won’t do that alone, so I’m assuming you did some further filtering within the template file?

I’ve attempted to compensate and even go back to pagination and it does work, but the per_page defaults to 10 no matter what number I put in, 20, 25, 50, or 100… all resulting in about 90 pages of pagination and its just an awful mess.

Where are you changing per_page?

The ‘limit’ attribute sets the post_per_page value on the query, but by default, it should default to a high value (1000) not 10.

Is there any way I can change this number to per_page=100?

Add the limit attribute, limit=100 for example.

And show only past events?

EE doesn’t have an option to show only past events, you mentioned you had this working previously so I’m guessing you have some custom code in the template to do that for you?

OR how can I ensure that espresso-events-table-template.template.php is being recognized?

You can add something like this:

<?php echo '<h1>' . __FILE__ . '</h1>'; ?>

To your custom template just after the do_action call, so on the link for Josh’s example line 13 is fine, on the current versions its line 17 – http://take.ms/AHHLN

Then load the page, and see if you see the path to your custom file output to the page – http://take.ms/J9bmf

Can you link me to the page so I can see what events are being pulled? Using the above shortcode that you posted on the latest version of the Events Table, default template loads the events that I would expect.


kellyjo

October 5, 2017 at 1:05 am

Hey Tony, thanks for your response.

As I said, the template file has been modified to filter the dates. So I’m simply checking to see IF event date < currentdate OR event date = expired then show.

I am taking that code from Josh which is looping through the posts to show events and then applying the filter which should render it to be showing me ALL expired events, but yet its cut off as if it somehow is limited to displaying no more than 25 events or so. Do you think it could be a memory limit cutting out?

To get into more detail, I began receiving memory limit errors with Event Espresso, unable to access the backend at all, but was able to fix it by increasing the memory from around 256M to 512M and then 1024M. But it still doesn’t seem to be working correctly.

As for setting the limit=100… then it only shows the up to 100 events and nothing else. I need to show ALL expired events.. and right now I can only do that with those 88 pages of pagination.


kellyjo

October 5, 2017 at 1:36 am

Tony, my problem seems to be… not of the dates going back or the expired, but the limitation for how far back I can go from this file. I can’t recall it being an issue before. It seems I can go back to events as far back as July 30, 2017. However, any events before that date… and we’ve been using Event Espresso since about April 2016…. aren’t showing at all.


$geteventdate = $post->EE_Event->first_datetime();
$eventdate = date('Y-m-d', strtotime($geteventdate->start_date()));
$getcurrentdate = date('Y-m-d');
if($eventdate < $getcurrentdate) {
...
}


Tony

  • Support Staff

October 6, 2017 at 4:00 am

As I said, the template file has been modified to filter the dates. So I’m simply checking to see IF event date < currentdate OR event date = expired then show.

I understand you’re filtering the events, but it wasn’t clear if you’re altering the query to pull expired events, or just checking the dates of all your events within the template, you’re doing the latter.

I am taking that code from Josh which is looping through the posts to show events and then applying the filter which should render it to be showing me ALL expired events, but yet its cut off as if it somehow is limited to displaying no more than 25 events or so.

If you install Debug bar on the site, load up the page with the table view template and check the ‘queries’ tab.

Search for ‘SELECT SQL_CALC_FOUND_ROWS wp_posts.’ and post the query here, please.

This is mine using the latest version of the Table view template – http://take.ms/Ph2S1

That pulls all of my events.

If you temporarily rename your template file so that EE uses the default (just add -temp to the filename) and retest, do you get all your events?

Do you think it could be a memory limit cutting out?

Possibly, although you would normally see an error in the error logs if that happens.

To get into more detail, I began receiving memory limit errors with Event Espresso, unable to access the backend at all, but was able to fix it by increasing the memory from around 256M to 512M and then 1024M. But it still doesn’t seem to be working correctly.

The amount of memory you use depends on multiple different factors, but pulling in all of your events then looping through them is going to use a fair amount.

Is it just the template that isn’t working are other areas?


kellyjo

October 11, 2017 at 3:36 am

Hey Tony,

Took me a few days to get around to do the testing in your reply.

1. If you install Debug bar on the site, load up the page with the table view template and check the ‘queries’ tab.

I’ve installed the bar (wp_config.php debug to true) and attempted to track down these errors.. or warnings, do you think they would be affecting why all listings of the past are not showing up?

Request:

events-list-archive

Query String:

pagename=events-list-archive

Matched Rewrite Rule:

(.?.+?)(?:/([0-9]+))?/?$

Matched Rewrite Query:

pagename=events-list-archive&page=

TOTAL WARNINGS:
0
TOTAL NOTICES:
8 (each one of these below was duplicated for some reason)

NOTICE: wp-content/plugins/equivalent-mobile-redirect/equivalent-mobile-redirect.php:250 – Undefined index: emrall
require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.php’), do_action(‘template_redirect’), WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, NDG_Speedy_Page_Redirect->template_redirect

>>> possible plugin conflict? since the theme is not responsive nor event espresso, this changes the website to show a different page in mobile (in which we use Event Espresso’s list view instead of the calendar)

NOTICE: wp-content/plugins/functions.php:375 – Trying to get property of non-object
require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.php’), include(‘/themes/ascent/page-full-width.php’), get_template_part, locate_template, load_template, require(‘/themes/ascent/content-page.php’), the_content, apply_filters(‘the_content’), WP_Hook->apply_filters, call_user_func_array, do_shortcode, preg_replace_callback, do_shortcode_tag, call_user_func, EES_Espresso_Events_Table_Template->process_shortcode, EEH_Template::locate_template, EEH_Template::display_template, include(‘/uploads/espresso/templates/espresso-events-table-template.template.php’), the_post_thumbnail, get_the_post_thumbnail, apply_filters(‘post_thumbnail_html’), WP_Hook->apply_filters, call_user_func_array, post_thumbnail_html

>>>

>>>>>> this was a code i found to prevent the event espresso featured image from doing weird things — like when you hovered over it, it would “zoom” — this makes the image normal.

//DISABLE THE IMAGE CLICK FOR FEATURED IMAGE ON EVENTS PAGE

add_filter( ‘post_thumbnail_html’, ‘post_thumbnail_html’, 10, 3 );
function post_thumbnail_html( $html, $post_id, $post_image_id ) {
//if(get_post_type(‘espresso_events’)) {
$img_ID = get_post_thumbnail_id( $post->ID ); //375
$featured_img = wp_get_attachment_image_src( $img_ID, ‘large’ );
$img_url = $featured_img[0];
$html = ‘‘;
return $html;
//}
}

<<<

NOTICE: wp-content/uploads/espresso/templates/espresso-events-table-template.template.php:241 – Undefined variable: startdat
require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.php’), include(‘/themes/ascent/page-full-width.php’), get_template_part, locate_template, load_template, require(‘/themes/ascent/content-page.php’), the_content, apply_filters(‘the_content’), WP_Hook->apply_filters, call_user_func_array, do_shortcode, preg_replace_callback, do_shortcode_tag, call_user_func, EES_Espresso_Events_Table_Template->process_shortcode, EEH_Template::locate_template, EEH_Template::display_template, include(‘/uploads/espresso/templates/espresso-events-table-template.template.php’)

>>> $startdat = $datetime->start_date_and_time(); //looks defined to me, do i need to set it as a global?

2. If you temporarily rename your template file so that EE uses the default (just add -temp to the filename) and retest, do you get all your events?
>> File was renamed. table_paging set to false to turn off pagination. I do not get all the events showing up, it only goes back to 2 days prior to today.

3. This is mine using the latest version of the Table view template – http://take.ms/Ph2S1
>> Where might I put this code? There doesn’t seem to be any direct calls to the database from the template file.

4. Is it just the template that isn’t working are other areas?

All other areas seem to be working. I have 1 template, but within that template, which is inside of a loop of the database, I am looking at the page URL and determining what should be done based on that.
For example:
1. month-event-list = displays all events for the month (grabs the first date of the month and the last date and if the events date matches anything in between these 2 dates, it shows, otherwise it does not)
2. active-events = shows all ACTIVE events which is TODAY + FUTURE (no expired, no sold out)
3. events-list-archive = shows ALL events regardless if it is sold out, expired, future, etc. <- THIS IS NOT WORKING ANYMORE.. I can see all future events, but it only goes back to 2 days prior to today.


Tony

  • Support Staff

October 11, 2017 at 9:15 am

>>> possible plugin conflict? since the theme is not responsive nor event espresso, this changes the website to show a different page in mobile (in which we use Event Espresso’s list view instead of the calendar)

It’s not really a conflict, its the equivalent-mobile-redirect plugin trying to use values before checking the exist. That particular error is from that plugin trying to use the ’emrall’ options (from its own options) when its not set.

That should be fixed on their end.

>>>>>> this was a code i found to prevent the event espresso featured image from doing weird things — like when you hovered over it, it would “zoom” — this makes the image normal.

I’m fairly sure that’s not from Event Espresso, either way the code needs to check the object is valid before doing anything to it.

>>> $startdat = $datetime->start_date_and_time(); //looks defined to me, do i need to set it as a global?

No, you don’t need to make it global.

$datetimes will only be set if get_datetimes_for_event_ordered_by_start_time() returns some results, you have expired events showing in the table meaning that that method will not return datetimes for those events and then the warning is thrown.

>> File was renamed. table_paging set to false to turn off pagination. I do not get all the events showing up, it only goes back to 2 days prior to today.

Ok, so can you provide the results for the query I requested above.

3. events-list-archive = shows ALL events regardless if it is sold out, expired, future, etc. <- THIS IS NOT WORKING ANYMORE.. I can see all future events, but it only goes back to 2 days prior to today.

It sounds like the query is being filtered which is why I asked for the above.

Can you re-run through the steps above and post up the query that is being used to generate the table, like in my example screenshot.


kellyjo

October 12, 2017 at 4:21 am

Hey Tony,

I installed Query Monitor to get the database call as the Debug Bar wasn’t showing me queries. This was the only thing I could find that closely resembled your screenshot.

SQL_CALC_FOUND_ROWS:

SELECT SQL_CALC_FOUND_ROWS wp_posts.*, MIN( wp_esp_datetime.DTT_EVT_start ) as event_start_date 
FROM wp_posts 
INNER JOIN wp_esp_datetime
ON ( wp_posts.ID = wp_esp_datetime.EVT_ID ) 
WHERE 1=1 
AND wp_posts.post_type = 'espresso_events'
AND (wp_posts.post_status = 'publish'
OR wp_posts.post_status = 'cancelled'
OR wp_posts.post_status = 'postponed'
OR wp_posts.post_status = 'sold_out'
OR wp_posts.post_status = 'private')
AND wp_esp_datetime.DTT_EVT_end > '2017-10-12 10:04:29' 
GROUP BY wp_posts.ID 
ORDER BY event_start_date ASC
LIMIT 0, 1000

If it helps any, this is the full code I have in espresso-events-table-template.template.php with the Gist I gave above which sits below all the important workings in the beginning of the file.


  <?php //check the url for events-list-archive
        if(preg_match('/events-list-archive/', $getpage)) {
        $geteventdate = $post->EE_Event->first_datetime(); 
        $eventdate = date('Y-m-d', strtotime($geteventdate->start_date())); 
        $getcurrentdate = date('Y-m-d');
        if($eventdate < $getcurrentdate) { 
          if($event->is_sold_out()) { 
    		$live_button	= 'ID.'" class="a_register_link_sold_out" href="'.$registration_url.'">'.$sold_out_button_text.'';
       	  } else {
         $live_button	= 'ID.'" class="a_register_link_sold_out" href="'.$registration_url.'">Event Expired';
       	  }
		?>
    	<tr class="espresso-table-row <?php echo $category_slugs; ?>">
        <td class="event_title event-<?php echo $post->post_title; ?><br /><?php if ( has_post_thumbnail() ) : ?>
        <?php the_post_thumbnail(array(100, 100)); ?>
        <?php endif; ?></td>
        <td class="start_date event-<?php echo $post->ID; ?>" data-value="<?php strtotime( $startdat ); ?>"><?php echo espresso_list_of_event_dates_table_template(); ?></td> 
        <td class="day_of_week event-<?php echo $post->ID; ?>"><?php espresso_event_date_range( 'l', ' ', 'l', ' ', $event->ID() ); ?></td>
        <td class="td-group reg-col" nowrap="nowrap"><?php echo $ticket_price; ?></td>
        <td class="td-group reg-col" nowrap="nowrap"><?php echo $tickets_total; ?></td>
        <td class="td-group reg-col" nowrap="nowrap"><?php echo $tickets_sold; ?></td>
        <td class="td-group reg-col" nowrap="nowrap"><?php echo $eventinstructor; ?></td>
        <td class="td-group reg-col" nowrap="nowrap"><?php echo $eventnotes; ?></td>
        <td class="td-group reg-col" nowrap="nowrap"><?php echo $live_button; ?></td>
		</tr>
     	<?php
      	} }
        ?>

Just so you have an idea of how this table renders: https://goo.gl/2hgxd5


Tony

  • Support Staff

October 12, 2017 at 6:53 am

So in the query you can see this:

AND wp_esp_datetime.DTT_EVT_end > '2017-10-12 10:04:29'

Which means EE is only pulling in events with a date end set greater than now.

Filtering the events after that won’t show all events as the events aren’t there to filter.

Can you let me know the version number of the template add-on you are using, and the version of EE4 please, I’ll do some digging into this.


Tony

  • Support Staff

October 12, 2017 at 8:24 am

Can you double check that your shortcode has show_expired=true set? The above query is what should happen if show_expired is false.


kellyjo

October 16, 2017 at 12:15 am

Hey Tony, here is the template code:

[ESPRESSO_EVENTS_TABLE_TEMPLATE show_expired=true show_all_datetimes=true sort=DESC table_paging=true]

For now, I have table_paging set to true so my client can see events from a year ago. When set to false, we are not getting ALL events showing, as stated in earlier posts.

Event Espresso 4.9.45.p
Event Espresso – Events Table View Template Version 1.3.6.p


Tony

  • Support Staff

October 16, 2017 at 5:30 am

Can you create a new test page and add the original shortcode without paging on that page so I can view it, please?

If you don’t want to post the link here then just let me know the page slug and I’ll find it from that on your site.


kellyjo

October 16, 2017 at 5:29 pm

Hey Tony,

This page will lead you to the link that will take you directly to the website. As this is a client of mine, and I do respect her right to privacy, just let me know when you have the link so I can delete that page.

https://mypost.io/post/kjtestpage

Remember: The template is still the same, but now allows for this new test page to load all the events by looking at the URL.

Note: Give it a few … the total memory on the server is 1 GB and it may take a minute or 2 to load.

Also: The very first listed class was April 1, 2016 12:00 am. My client wishes for ALL events, expired, sold out, etc. to be shown on a single page.

I do understand that this could cause a severe delay from the database, but I’m not sure why it would be limited to not showing more. Could we be limited via the host?

Each page in the backend of WordPress shows 100 events per page, so it is showing around 10 pages each. However, even with any template code for the front end, such as showing 100 events per page would be ideal, it is currently only showing 10 or so at a time, regardless of what number I put into the code.

I’ve also set the paging to false.


Tony

  • Support Staff

October 17, 2017 at 1:41 am

Now I can see the output, I think the problem is the default table_pages value.

All ~800 of your events are loading on the page – http://take.ms/URsaR

However, the template does a couple of checks when loading which is affecting the output and setting display: none; on the rows over 100. It checks if table_paging is set to false and if so, sets table_pages to 100 by default, your table shows 100 events and then hides the others.

Try adding table_pages=2000 to your shortcode, do the additional events show then?

If not I’ll need access to the site to investigate this further, the query you posted above doesn’t match the output as its pulling events with a DTT_EVT_end less than now (expired events) so I need to dig a little deeper.


kellyjo

November 1, 2017 at 1:53 am

Hey Tony,

This is now fully functional and working.

The site was sitting on Shared Hosting which has its limitations.

You can read about the details about what happened here: https://eventespresso.com/topic/event-espresso-data-and-database-usage/

Definitely a journey… and a learned experience.

When put onto a VPS or Cloud server, it has a chance to spread its wings. So… loading that many database entries on to a page… might take a minute or two, but the results are that it is showing all the records.

I do appreciate your help.

So… this ISSUE has been RESOLVED.


Tony

  • Support Staff

November 1, 2017 at 3:49 am

Great, I’m glad it’s now working.

I’ll mark this thread resolved.

Viewing 16 reply threads

The support post ‘ESPRESSO_EVENTS_TABLE_TEMPLATE issues’ 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