[EventCalendar] recoding in-post events

Adam Houston adam at brickst.com
Thu Mar 12 03:29:15 UTC 2009


Morten -

I did the same thing. Here's the code I use...I haven't had it this  
way for very long so who knows if issues may arise later. But for me,  
it has worked great. You can see it in place at http://www.haynerlibrary.org

Replace the appropriate section of "template-functions-new" with the  
following:



/** Formats the schedule for the current post as one or more 'iconlets'.
  *  Returns the HTML fragment as a string. */
function ec3_get_iconlets()
{
   if(!ec3_is_event())
     return '';

   global $ec3;
   $result='';
   $current=false;
   $this_year=date('Y');
   for($evt=ec3_iter_post_events(); $evt->valid(); $evt->next())
   {
     $year_start =ec3_get_start_date('Y');
     $month_start=ec3_get_start_date('M');
     $day_start  =ec3_get_start_date('j');
     // Don't bother about intra-day details.
     if($current==$day_start.$month_start.$year_start)
       continue;
     $current=$day_start.$month_start.$year_start;
     // Grey-out past events.
     if($ec3->event->active)
       $active ='';
     else
       $active =' ec3_past';
     // Only put the year in if it isn't *this* year.
     if($year_start!=$this_year)
       $month_start.=' ’'.substr($year_start,2);
     // OK, make the iconlet.
     $result.="<div";
     if(!$ec3->event->allday)
     {
       // Event with start time.
       $time_start=ec3_get_start_time();
       $result.=" class='ec3_iconlet$active'><span class='ec3_month'> 
$month_start</span>"
              . "<span class='ec3_day'>$day_start</span>"
              . "<span class='ec3_time'>$time_start</span>";
     }
     elseif(substr($ec3->event->start,0,10) == substr($ec3->event->end, 
0,10))
     {
       // Single, all-day event.
       $result.=" class='ec3_iconlet$active'><span class='ec3_month'> 
$month_start</span>"
              . "<span class='ec3_day'>$day_start</span>"
              . "<span class='ec3_time'>All day</span>";
     }
     else
     {
       // Multi-day event.
       $month_end=ec3_get_end_date('M');
       $day_end  =ec3_get_end_date('j');
	
		if($month_start==$month_end)
		{
		  $result.=" class='ec3_multi_iconlet$active'><span  
class='ec3_multi_month'>"
				 .  "<span class='ec3_multi_month_end'>$month_start</span></span>";
		}
		else
		{
		  $result.=" class='ec3_multi_iconlet$active'><span  
class='ec3_multi_month'>"
				 .  "<span class='ec3_multi_month_start'>$month_start</span>&ndash;"
				 .  "<span class='ec3_multi_month_end'>$month_end</span></span>";
		}
       $result.="<span class='ec3_multi_day'>"
              .  "<span class='ec3_multi_day_start'>$day_start</ 
span>&ndash;"
              .  "<span class='ec3_multi_day_end'>$day_end</span></ 
span>"
              . "<span class='ec3_multi_time'>All day</span>";
     }
     $result.="</div>\n";
   }
   return apply_filters( 'ec3_filter_iconlets', $result );
}




Thanks,

Adam Houston




On Mar 11, 2009, at 9:31 PM, Morten Rand-Hendriksen wrote:

> I want to restyle the box that shows up inside posts to fit with my  
> overall layout. The big problem is that it’s using tables which  
> makes it very hard to deal with. Can someone direct me towards where  
> in the plugin the actual in-post code is generated so I can convert  
> it to CSS instead of a clunky table? It’ll make it a lot easier to  
> style and position the box.
>
> Thanks
>
> morten
>
> _______________________________________________
> Blog: http://wpcal.firetree.net/
> EventCalendar at firetree.net mailing list
> Unsubscribe: http://penguin.firetree.net/eventcalendar








More information about the EventCalendar mailing list