Advertisement
Apina

Example modified EE4 table template - expired events

Jul 31st, 2015
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.11 KB | None | 0 0
  1. <?php
  2. // Options
  3. $date_format = get_option( 'date_format' );
  4. $time_format = get_option( 'time_format' );
  5. // Load Venue View Helper
  6. EE_Registry::instance()->load_helper('Venue_View');
  7. //Defaults
  8. $reg_button_text = !isset($reg_button_text) ? __('Register', 'event_espresso') : $reg_button_text;
  9. $alt_button_text = !isset($alt_button_text) ? __('View Details', 'event_espresso') : $alt_button_text;//For alternate registration pages
  10. $sold_out_button_text = !isset($sold_out_button_text) ? __('Sold Out', 'event_espresso') : $sold_out_button_text;//For sold out events
  11.  
  12. $exp_button_text = !isset($exp_button_text) ? __('Expired', 'event_espresso') : $exp_button_text;//For sold out events
  13.  
  14.  
  15. if ( have_posts() ) :
  16. // allow other stuff
  17. do_action( 'AHEE__espresso_events_table_template_template__before_loop' );
  18. ?>
  19.  
  20. <?php if ($category_filter != 'false'){ ?>
  21. <p class="category-filter">
  22. <label><?php echo __('Category Filter', 'event_espresso'); ?></label>
  23. <select class="" id="ee_filter_cat">
  24. <option class="ee_filter_show_all"><?php echo __('Show All', 'event_espresso'); ?></option>
  25. <?php
  26. $taxonomy = array('espresso_event_categories');
  27. $args = array('orderby'=>'name','hide_empty'=>true);
  28. $ee_terms = get_terms($taxonomy, $args);
  29.  
  30. foreach($ee_terms as $term){
  31. echo '<option class="' . $term->slug . '">'. $term->name . '</option>';
  32. }
  33. ?>
  34. </select>
  35. </p>
  36. <?php } ?>
  37.  
  38. <?php if ($footable != 'false' && $table_search != 'false'){ ?>
  39. <p>
  40. <?php echo __('Search:', 'event_espresso'); ?> <input id="filter" type="text"/>
  41. </p>
  42. <?php } ?>
  43.  
  44. <table id="ee_filter_table" class="espresso-table footable table" data-page-size="<?php echo $table_pages; ?>" data-filter="#filter">
  45. <thead class="espresso-table-header-row">
  46. <tr>
  47. <th class="th-group"><?php _e('Event','event_espresso'); ?></th>
  48. <th class="th-group"><?php _e('Venue','event_espresso'); ?></th>
  49. <th class="th-group"><?php _e('Date','event_espresso'); ?></th>
  50. <th class="th-group" data-sort-ignore="true"></th>
  51. </tr>
  52. </thead>
  53. <?php if ($footable != 'false' && $table_paging != 'false'){ ?>
  54. <tfoot>
  55. <tr>
  56. <td colspan="4">
  57. <div class="pagination pagination-centered"></div>
  58. </td>
  59. </tr>
  60. </tfoot>
  61. <?php } ?>
  62. <tbody>
  63.  
  64. <?php
  65. // Start the Loop.
  66. while ( have_posts() ) : the_post();
  67. // Include the post TYPE-specific template for the content.
  68. global $post;
  69.  
  70. //Debug
  71. //d( $post );
  72.  
  73. //Get the category for this event
  74. $event = EEH_Event_View::get_event();
  75. if ( $event instanceof EE_Event ) {
  76. if ( $event_categories = get_the_terms( $event->ID(), 'espresso_event_categories' )) {
  77. // loop thru terms and create links
  78. $category_slugs = '';
  79. foreach ( $event_categories as $term ) {
  80. $category_slugs[] = $term->slug;
  81. }
  82. $category_slugs = implode(' ', $category_slugs);
  83. } else {
  84. // event has no terms
  85. $category_slugs = '';
  86. }
  87.  
  88. }
  89. //Create the event link
  90. $external_url = $post->EE_Event->external_url();
  91. $button_text = !empty($external_url) ? $alt_button_text : $reg_button_text;
  92. $registration_url = !empty($external_url) ? $post->EE_Event->external_url() : $post->EE_Event->get_permalink();
  93.  
  94. //Create the register now button
  95. $live_button = '<a id="a_register_link-'.$post->ID.'" href="'.$registration_url.'">'.$button_text.'</a>';
  96.  
  97. if ( $event->is_sold_out() || $event->is_sold_out(TRUE ) ) {
  98. $live_button = '<a id="a_register_link-'.$post->ID.'" class="a_register_link_sold_out" href="'.$registration_url.'">'.$sold_out_button_text.'</a>';
  99. }
  100.  
  101. if ( $event->is_upcoming() || $event->is_upcoming(TRUE ) ) {
  102. $live_button = '<a id="a_register_link-'.$post->ID.'" class="a_register_link_sold_out" href="'.$registration_url.'">'.$exp_button_text.'</a>';
  103. }
  104.  
  105. $datetimes = EEM_Datetime::instance()->get_datetimes_for_event_ordered_by_start_time( $post->ID, $show_expired, false, 1 );
  106.  
  107. $datetime = end( $datetimes );
  108.  
  109. //let's use date_i18n on the correct offset for the timestamp. Note it seems like we're doing a lot of
  110. //unnecessary conversion but this is so it works with two different pardigmas in the EE core datetime
  111. //system, without users having to worry about updating.
  112. $startdate = date_i18n( $date_format . ' ' . $time_format, strtotime( $datetime->start_date_and_time('Y-m-d', 'H:i:s') ) );
  113.  
  114. ?>
  115. <tr class="espresso-table-row <?php echo $category_slugs; ?>">
  116. <td class="event_title event-<?php echo $post->ID; ?>"><?php echo $post->post_title; ?></td>
  117. <td class="venue_title event-<?php echo $post->ID; ?>"><?php espresso_venue_name( NULL, FALSE ); ?></td>
  118. <td class="start_date event-<?php echo $post->ID; ?>" data-value="<?php echo $datetime->get_raw( 'DTT_EVT_start' ); ?>"><?php echo $startdate; ?></td>
  119. <td class="td-group reg-col" nowrap="nowrap"><?php echo $live_button; ?></td>
  120. </tr>
  121. <?php
  122.  
  123.  
  124. endwhile;
  125. echo '</table>';
  126. // allow moar other stuff
  127. do_action( 'AHEE__espresso_events_table_template_template__after_loop' );
  128.  
  129. else :
  130. // If no content, include the "No posts found" template.
  131. espresso_get_template_part( 'content', 'none' );
  132.  
  133. endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement