[EventCalendar] ordering events category like upcoming list: a few ideas?

npessoa at umich.edu npessoa at umich.edu
Thu Feb 15 20:29:21 UTC 2007


Hi, Alex:

I upgraded to EC 3.1.1, but it didn't do anything to alter the order of 
the events.

I know there are people out there using the plugin in similar ways, so 
how are they getting their event lists to sort from Now > Future?

The only thing I can think of is to somehow create a static page called 
"Events" and insert the <php> for the upcoming list, or to delete the 
"Filed under Events" link altogether so people can't see the category 
itself, which is out of order.

OR... and this is a stretch, because I'm by no means a php goddess, but 
I found this snippet of code in eventcalendar.php:

----- CODE EXCERPT ------

/** Change the order of event listings (only advanced mode). */
function ec3_filter_posts_orderby(&$orderby)
{
  global $ec3;
  $regexp='/\bpost_date\b( DESC\b| ASC\b)?/i';
  if($ec3->order_by_start && preg_match($regexp,$orderby,$match))
  {
    if($match[1] && $match[1]==' DESC')
      $orderby=preg_replace($regexp,'ec3_sch.start',$orderby);
    else
      $orderby=preg_replace($regexp,'ec3_sch.start DESC',$orderby);
  }
  return $orderby;
}
----- END CODE EXCERPT ------

I'm not "fluent" in php, but it looks like $regexp is ordering the 
posts by post_date. Could this be modified to end_date or whatever 
function EC3 uses to dictate the expiration date of an event?

I could make a custom template for the Events category -- would this 
help? Would I be able to insert a query for the 'upcoming list' format 
in this way? It seems like one way or another the user will eventually 
get to the "Events" Category, so it would be great to just be able to 
re-order this from Earliest > Latest like I want.

Thank you for your help - this is the last bit of functionality I have 
to get resolved before I can finish this site over the weekend!! :)





More information about the EventCalendar mailing list