Created
August 16, 2012 15:51
-
-
Save joshfeck/3371265 to your computer and use it in GitHub Desktop.
Alternate movie table template. Removes category filtering and adds film title. Use in place of the stock movie list table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Shortcode Name: Espresso Table | |
Author: Seth Shoultes | |
Contact: | |
Website: http://www.eventespresso.com | |
Description: Modified movie listing like table. Allows you to show events within a certain number number of days into the future and a qty. The example below only shows 3 events that start within 30 days from the current date. | |
Usage Example: [ESPRESSO_MOVIE_TABLE max_days="30" qty="3"] | |
Custom CSS for the table display | |
Notes: This file should be stored in your "/wp-content/uploads/espresso/templates/" folder and you should have the custom_includes.php files installed in your "/wp-content/uploads/espresso/" directory. | |
*/ | |
function espresso_display_movie_table($max_days="", $qty="10"){ | |
global $wpdb; | |
//$org_options = get_option('events_organization_settings'); | |
//$event_page_id =$org_options['event_page_id']; | |
//testing if we got the cat and day filters (it works) | |
/*echo $event_category_id; | |
echo $max_days; | |
echo $qty;*/ | |
$sql = "SELECT e.*, ese.start_time, ese.end_time FROM ". EVENTS_DETAIL_TABLE . " e "; | |
$sql .= " JOIN " . EVENTS_START_END_TABLE . " ese ON ese.event_id = e.id "; | |
//$sql .= " JOIN " . EVENTS_CATEGORY_REL_TABLE . " r ON r.event_id = e.id "; | |
//$sql .= " JOIN " . EVENTS_CATEGORY_TABLE . " c ON c.id = r.cat_id "; | |
$sql .= " WHERE e.is_active = 'Y' "; | |
$sql .= " AND event_status != 'D' "; | |
$sql .= " AND event_status != 'S' "; | |
//$sql .= " AND c.category_identifier = '" . $category_id . "' "; | |
if ($max_days != ""){ | |
$sql .= " AND ADDDATE('".date ( 'Y-m-d' )."', INTERVAL ".$max_days." DAY) >= e.start_date AND e.start_date >= '".date ( 'Y-m-d' )."' "; | |
} | |
$sql .= " ORDER BY date(e.start_date), ese.start_time "; | |
$sql .= " LIMIT 0," . $qty; | |
espresso_get_movie_tabe($sql); | |
$content = ob_get_contents(); | |
return $content; | |
} | |
//Events Custom Table Listing - Shows the events on your page in matching table. | |
function espresso_get_movie_tabe($sql){ | |
global $wpdb, $org_options; | |
//echo 'This page is located in ' . get_option( 'upload_path' ); | |
$event_page_id = $org_options['event_page_id']; | |
$currency_symbol = $org_options['currency_symbol']; | |
$events = $wpdb->get_results($sql); | |
//$category_name = $wpdb->last_result[0]->category_name; | |
//$category_desc = $wpdb->last_result[0]->category_desc; | |
// $display_desc = $wpdb->last_result[0]->display_desc; | |
//if ($display_desc == 'Y'){ | |
// echo '<p>' . stripslashes_deep($category_name) . '</p>'; | |
// echo '<p>' . stripslashes_deep($category_desc) . '</p>'; | |
//} | |
?> | |
<table class="espresso-table"> | |
<tr> | |
<th id="th-group"><?php _e('Film','event_espresso'); ?></th> | |
<th id="th-group"><?php _e('Date','event_espresso'); ?></th> | |
<th id="th-group"><?php _e('Time','event_espresso'); ?></th> | |
<th id="th-group"><?php _e('Tickets','event_espresso'); ?></th> | |
</tr> | |
<?php | |
foreach ($events as $event){ | |
$reg_limit = $event->reg_limit; | |
$event_desc = wpautop($event->event_desc); | |
$live_button = '<a id="a_register_link-'.$event->id.'" href="'.get_option('siteurl').'/?page_id='.$event_page_id.'®event_action=register&event_id='.$event->id.'&name_of_event='.stripslashes_deep($event->event_name).'">Buy Now</a>'; | |
//Check to see how many open spots are available | |
$open_spots = get_number_of_attendees_reg_limit($event->id, 'available_spaces') == 'Unlimited' ? 999 : get_number_of_attendees_reg_limit($event->id, 'available_spaces'); | |
//echo $open_spots; | |
if ( $open_spots < 1 ) { $live_button = 'Closed'; } | |
?> | |
<tr class=""> | |
<td class="td-group"> | |
<?php echo $event->event_name ?> | |
</td> | |
<td class="td-group"> | |
<?php echo event_date_display($event->start_date, $format = 'M d Y') ?> | |
</td> | |
<td class="td-group"> | |
<?php echo $event->start_time ?> | |
</td> | |
<td class="td-group"> | |
<?php echo $live_button ?> | |
</td> | |
</tr> | |
<?php } //close foreach ?> | |
</table> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment