Advertisement
Apina

EE4 custom table template to show multiple datetimes

Feb 23rd, 2015
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.87 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. if ( have_posts() ) :
  13. // allow other stuff
  14. do_action( 'AHEE__espresso_events_table_template_template__before_loop' );
  15. ?>
  16.  
  17. <?php if ($category_filter != 'false'){ ?>
  18. <p class="category-filter">
  19. <label><?php echo __('Category Filter', 'event_espresso'); ?></label>
  20. <select class="" id="ee_filter_cat">
  21. <option class="ee_filter_show_all"><?php echo __('Show All', 'event_espresso'); ?></option>
  22. <?php
  23. $taxonomy = array('espresso_event_categories');
  24. $args = array('orderby'=>'name','hide_empty'=>true);
  25. $ee_terms = get_terms($taxonomy, $args);
  26.  
  27.  
  28.  
  29. foreach($ee_terms as $term){
  30. echo '<option class="' . $term->slug . '">'. $term->name . '</option>';
  31. }
  32. ?>
  33. </select>
  34.  
  35.  
  36. </p>
  37. <?php } ?>
  38.  
  39. <?php if ($footable != 'false' && $table_search != 'false'){ ?>
  40. <p>
  41. <?php echo __('Search:', 'event_espresso'); ?> <input id="filter" type="text"/>
  42. </p>
  43. <?php } ?>
  44.  
  45. <table id="ee_filter_table" class="espresso-table footable table" data-page-size="<?php echo $table_pages; ?>" data-filter="#filter">
  46. <thead class="espresso-table-header-row">
  47. <tr>
  48. <th class="th-group"><?php _e('Event','event_espresso'); ?></th>
  49. <th class="th-group"><?php _e('Venue','event_espresso'); ?></th>
  50. <th class="th-group"><?php _e('Date','event_espresso'); ?></th>
  51. <th class="th-group" data-sort-ignore="true"></th>
  52. </tr>
  53. </thead>
  54. <?php if ($footable != 'false' && $table_paging != 'false'){ ?>
  55. <tfoot>
  56. <tr>
  57. <td colspan="4">
  58. <div class="pagination pagination-centered"></div>
  59. </td>
  60. </tr>
  61. </tfoot>
  62. <?php } ?>
  63. <tbody>
  64.  
  65. <?php
  66. // Start the Loop.
  67. while ( have_posts() ) : the_post();
  68. // Include the post TYPE-specific template for the content.
  69. global $post;
  70.  
  71. //Debug
  72. //d( $post );
  73.  
  74. //Get the category for this event
  75. $event = EEH_Event_View::get_event();
  76.  
  77. //echo "<pre>" . print_r($event, 1). "</pre>";
  78.  
  79. if ( $event instanceof EE_Event ) {
  80.  
  81. if ( $event_categories = get_the_terms( $event->ID(), 'espresso_event_categories' )) {
  82. // loop thru terms and create links
  83. $category_slugs = '';
  84. foreach ( $event_categories as $term ) {
  85. $category_slugs[] = $term->slug;
  86. }
  87. $category_slugs = implode(' ', $category_slugs);
  88. } else {
  89. // event has no terms
  90. $category_slugs = '';
  91. }
  92.  
  93. }
  94. //Create the event link
  95. $external_url = $post->EE_Event->external_url();
  96. $button_text = !empty($external_url) ? $alt_button_text : $reg_button_text;
  97. $registration_url = !empty($external_url) ? $post->EE_Event->external_url() : $post->EE_Event->get_permalink();
  98.  
  99. //Create the register now button
  100. $live_button = '<a id="a_register_link-'.$post->ID.'" href="'.$registration_url.'">'.$button_text.'</a>';
  101.  
  102. if($event->display_ticket_selector() == 0) { $live_button = '<a id="a_register_link-'.$post->ID.'" href="'.$registration_url.'">' . __('View', 'event_espresso') . '</a>'; }
  103.  
  104. if ( $event->is_sold_out() || $event->is_sold_out(TRUE ) ) {
  105. $live_button = '<a id="a_register_link-'.$post->ID.'" class="a_register_link_sold_out" href="'.$registration_url.'">'.$sold_out_button_text.'</a>';
  106. }
  107.  
  108.  
  109. $datetimes = EEM_Datetime::instance()->get_datetimes_for_event_ordered_by_start_time( $post->ID, $show_expired, false, NULL );
  110.  
  111. //echo "<pre>" . print_r($datetimes,1 ) . "</pre>";
  112.  
  113. $startdat = '';
  114.  
  115. foreach ( $datetimes as $datetime ) {
  116.  
  117. $startdat .= $datetime->get('DTT_EVT_start') . "<br>";
  118.  
  119. }
  120.  
  121. //var_dump($startdat);
  122.  
  123. ?>
  124. <tr class="espresso-table-row <?php echo $category_slugs; ?>">
  125. <td class="event_title event-<?php echo $post->ID; ?>"><?php echo $post->post_title; ?></td>
  126. <td class="venue_title event-<?php echo $post->ID; ?>"><?php espresso_venue_name( NULL, FALSE ); ?></td>
  127. <td class="start_date event-<?php echo $post->ID; ?>" data-value="<?php echo strtotime( $startdat ); ?>"><?php echo $startdat; //date_i18n( $date_format . ' ' . $time_format, strtotime( $startdat ) ); ?></td>
  128. <td class="td-group reg-col" nowrap="nowrap"><?php echo $live_button; ?></td>
  129. </tr>
  130. <?php
  131.  
  132.  
  133. endwhile;
  134. echo '</table>';
  135. // allow moar other stuff
  136. do_action( 'AHEE__espresso_events_table_template_template__after_loop' );
  137.  
  138. else :
  139. // If no content, include the "No posts found" template.
  140. espresso_get_template_part( 'content', 'none' );
  141.  
  142. endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement