[EventCalendar] Update to template-functions.php

Isaac Rowntree isaac at zackdesign.biz
Wed Jan 30 13:43:01 UTC 2008


Hi,
        
        I would really like to move that the Event Calendar
        template-functions.php file be updated to support the following
        functionality. You'll see some comments prefacing where I've
        added code.
        
        It's really important that the widget support end dates now as
        well!!!
        You may need to add further code for events that stretch for a
        long
        period of time that aren't 'all day'. 
        
        >From line 379 on:
        
        
        -----------------------------------------------------
        
          // Find the upcoming events.   I've added 'end' here
          $calendar_entries = $wpdb->get_results(
            "SELECT DISTINCT
               p.id AS id,
               post_title,
               start,
               end,
               u.$ec3->wp_user_nicename AS author,
               allday
             FROM $ec3->schedule s
             LEFT JOIN $wpdb->posts p ON s.post_id=p.id
             LEFT JOIN $wpdb->users u ON p.post_author = u.id
             WHERE p.post_status='publish'
               AND end>='$ec3->today' $and_before
             ORDER BY start $limit_numposts"
          );
        
          echo "<ul class='ec3_events'>";
          echo "<!-- Generated by Event Calendar v$ec3->version -->\n";
          if($calendar_entries)
          {
            $time_format=get_option('time_format');
            $current_month=false;
            $current_date=false;
            $data=array();
            foreach($calendar_entries as $entry)
            {
              // To use %SINCE%, you need Dunstan's 'Time Since' plugin.
              if(function_exists('time_since'))
                  $data['SINCE']=time_since( time(),
        ec3_to_time($entry->start) );
        
              // Month changed?
              $data['MONTH']=mysql2date($month_format,$entry->start);
              if((!$current_month || $current_month!=$data['MONTH']) &&
        $template_month)
              {
                if($current_date)
                    echo "</ul></li>\n";
                if($current_month)
                    echo "</ul></li>\n";
                echo "<li class='ec3_list ec3_list_month'>"
                .    ec3_format_str($template_month,$data)."\n<ul>\n";
                $current_month=$data['MONTH'];
                $current_date=false;
              }
        
              // Date changed?
              $data['DATE'] =mysql2date($date_format, $entry->start);
              if((!$current_date || $current_date!=$data['DATE']) &&
        $template_day)
              {
                if($current_date)
                    echo "</ul></li>\n";
                echo "<li class='ec3_list ec3_list_day'>"
                .    ec3_format_str($template_day,$data)."\n<ul>\n";
                $current_date=$data['DATE'];
              }
              // Further modified below here
              if($entry->allday)
              {
                  if ($entry->end == $entry->start )
                      $data['TIME']=__('all day','ec3');
                  else
                      $data['TIME']=mysql2date('l jS F',$entry->start) .
        ' - ' .
        mysql2date('l jS F',$entry->end);
              }
              else
              {
                  if ($entry->end == $entry->start )
                      $data['TIME']=mysql2date($time_format,
        $entry->start);
                  else
                      $data['TIME']=mysql2date($time_format,
        $entry->start). ' -
        ' . mysql2date($time_format,$entry->end);
              }
        
        
        ----------------------------------------------------------
        
        Regards,
        Isaac
        
        
        




More information about the EventCalendar mailing list