Advertisement
BakerMan

Modified display_day() TEC 2.0 (3 events per day)

May 9th, 2013
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.42 KB | None | 0 0
  1. function display_day( $day, $monthView ) {
  2.     global $post;
  3.     $output = '';
  4.     $posts_per_page = 3; // Show no more than three
  5.     for ( $i = 0; $i < count( $monthView[$day] ) and $i < $posts_per_page; $i++ ) {
  6.         $post = $monthView[$day][$i];
  7.         setup_postdata( $post );
  8.         $eventId    = $post->ID.'-'.$day;
  9.         $start      = tribe_get_start_date( $post->ID, false, 'U' );
  10.         $end        = tribe_get_end_date( $post->ID, false, 'U' );
  11.         $cost       = tribe_get_cost( $post->ID );
  12.         ?>
  13.         <div id='event_<?php echo $eventId; ?>' <?php post_class('tribe-events-event tribe-events-real-event') ?>>
  14.             <a href="<?php tribe_event_link(); ?>"><?php the_title(); ?></a>
  15.             <div id='tooltip_<?php echo $eventId; ?>' class="tribe-events-tooltip" style="display:none;">
  16.                 <h5 class="tribe-events-event-title"><?php the_title();?></h5>
  17.                 <div class="tribe-events-event-body">
  18.                     <div class="tribe-events-event-date">
  19.                         <?php if ( !empty( $start ) )   echo date_i18n( get_option('date_format', 'F j, Y'), $start);
  20.                         if ( !tribe_get_event_meta($post->ID, '_EventAllDay', true) )
  21.                             echo ' ' . date_i18n( get_option('time_format', 'g:i a'), $start); ?>
  22.                         <?php if ( !empty( $end )  && $start !== $end ) {
  23.                             if ( date_i18n( 'Y-m-d', $start ) == date_i18n( 'Y-m-d', $end ) ) {
  24.                                 $time_format = get_option( 'time_format', 'g:i a' );
  25.                                 if ( !tribe_get_event_meta($post->ID, '_EventAllDay', true) )
  26.                                     echo " – " . date_i18n( $time_format, $end );
  27.                             } else {
  28.                                 echo " – " . date_i18n( get_option('date_format', 'F j, Y'), $end);
  29.                                 if ( !tribe_get_event_meta($post->ID, '_EventAllDay', true) )
  30.                                     echo ' ' . date_i18n( get_option('time_format', 'g:i a'), $end) . '<br />';
  31.                             }
  32.                         } ?>
  33.                     </div>
  34.                     <?php if ( function_exists('has_post_thumbnail') && has_post_thumbnail() ) { ?>
  35.                         <div class="tribe-events-event-thumb"><?php the_post_thumbnail( array(75,75));?></div>
  36.                     <?php } ?>
  37.                     <?php echo has_excerpt() ? TribeEvents::truncate($post->post_excerpt) : TribeEvents::truncate(get_the_content(), 30); ?>
  38.  
  39.                 </div>
  40.                 <span class="tribe-events-arrow"></span>
  41.             </div>
  42.         </div>
  43.         <?php
  44.  
  45.         if( $i < count( $monthView[$day] ) - 1 ) {
  46.             echo "<hr />";
  47.         }
  48.     }
  49.  
  50.     if ($posts_per_page < count( $monthView[$day] )) {
  51.         $difference = count ( $monthView[$day] ) - $posts_per_page;
  52.         echo _n("&hellip; and $difference more event", "&hellip; and $difference more events", $difference);
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement