[EventCalendar] ordering events category: one step closer -SIMPLE question

npessoa at umich.edu npessoa at umich.edu
Fri Feb 16 00:02:31 UTC 2007


Ray, thank you, I appreciate the detailed response. I will have to take 
the time to review it closely, because I am not familiar with php and 
mysql queries at all, apart from what I've learned in working with WP 
for the past week.

Your workaround sounds great, but I'm still surprised that something 
this complex is necessary to make EventCalendar sort the events in what 
to me seems like the most obvious, user-friendly way.

I've run across sites with similar event listings (like 
http://www.uncoolkids.com). Are the people running these sites 
implementing workarounds like this, or do they just post their material 
in order that they want and NEVER edit, so as not to mess with the 
timestamp property?

Where exactly, and in which file, would I want to paste your workaround 
code, if that's the solution I end up going with?

Thanks again,

Nadia

Quoting Ray Petrie <ray at heritagepark.com>:

> Nadia, I have been working on the same thing for over a month off and on. It
> was a good way to get familiar with php, mysql and phpmyadmin. I figured out
> how to do a query with left joins using the separate table with the start
> date and the category table.  It worked except that you had to put error
> traps in for the end of listings and pagination. Here is part of the code if
> you want to review it.  This is not the modular way that coding is done on
> wordpress and ec3 and I think there may be a way to do it with the existing
> code in ec3.
> *******************************************************
> if ( !(in_category('1')) && (!$wp_query->is_date) ) {
> // sort by start date and limit display to records for today and the future
> //$posts = query_posts($query_string . '&orderby=title&order=asc'); this
> works, but not what I want
> // query_posts('cat=7&orderby=title'); this does not consider start date
>
> $posts = $wpdb->get_results("select * from (wp_posts left join
> wp_ec3_schedule on wp_posts.ID=wp_ec3_schedule.post_id)  left join
> wp_post2cat on wp_ec3_schedule.post_id = wp_post2cat.post_id WHERE
> wp_ec3_schedule.start >= NOW() AND wp_post2cat.category_id = $cat ORDER BY
> start",OBJECT);
>
> // run the query again just to get a record count
> $query = "SELECT COUNT(*) FROM (wp_posts left join wp_ec3_schedule on
> wp_posts.ID=wp_ec3_schedule.post_id)  left join wp_post2cat on
> wp_ec3_schedule.post_id = wp_post2cat.post_id WHERE wp_ec3_schedule.start >=
> NOW() AND wp_post2cat.category_id = $cat ORDER BY start";
> $post_count = $wpdb->get_var($query);
> }
> *******************************************************
> I fine tuned my query by running it with phpmyadmin until I got the results
> I was looking for. Then I plugged it into the wordpress archive.php file
> before the have_posts()
> Use the post_count variable to know how many entries there are and a counter
> in The Loop to trap for time to break from the loop.  Figuring out how to do
> the pagination was so perplexing that I gave up.
>
> It looks like you can use the info from
> http://wpcal.firetree.net/advanced-queries/  because is says it will be
> sorted by the start date.  But it does not seem to be when I do it.
> ?ec3_days=N
>
> This works to provide the rss feed in date order for next 7 days
> http://blog.address/wp-rss.php?ec3_days=7
>
> You could use the function ec3_the_schedule() and perhaps modify it to show
> more data.
>
> Another way, not pretty, is to write a php routine to update the database
> putting the start date in as the post date.  I didn't do that because I
> still think it can be done with the code already present.
>
> Something to think about?
>
> Ray
>
>
>
>
> _______________________________________________
> Blog: http://wpcal.firetree.net/
> EventCalendar at firetree.net mailing list
> Unsubscribe: http://penguin.firetree.net/eventcalendar
>
>
>





More information about the EventCalendar mailing list