[EventCalendar] Re: WordPress Categories generate error (EC
3.1._pre14)
Steve Winton
stevewinton at gmail.com
Tue Oct 3 14:38:56 UTC 2006
hi Alex
You suggested the following to get round the categories error:
Try this...
>
> Index: eventcalendar3.php
> ===================================================================
> --- eventcalendar3.php (revision 163)
> +++ eventcalendar3.php (working copy)
> @@ -252,7 +252,7 @@
> {
> global $ec3,$wpdb;
> // The necessary joins are decided upon in ec3_filter_posts_where().
> - if($ec3->join_post2cat && !preg_match("/ JOIN +$wpdb->post2cat
> +/i",$join))
> + if($ec3->join_post2cat)
> {
> $join.=" LEFT JOIN $wpdb->post2cat ec3_post2cat ON
> ec3_post2cat.post_id=id";
> }
>
>
> -Alex
I tried the above, but also had to make one other change, as the SQL
contained an ambiguous reference to the category_id column. In
eventcalendar3.php, in ec3_filter_posts_where function, I have added the
following lines (encapsulated with !!! SW Begin and !!! SW End comments) to
modify the where clause:
elseif($ec3->advanced):
if($ec3->is_listing):
// Hide inactive events
$where.=" AND ec3_sch.post_id IS NOT NULL ";
$ec3->join_ec3_sch=true;
$ec3->join_only_active_events=true;
$ec3->order_by_start=true;
elseif($wp_query->is_search):
$where.=" AND (ec3_sch.post_id IS NOT NULL OR "
. "ec3_post2cat.category_id!=$ec3->event_category)";
$ec3->join_ec3_sch=true;
$ec3->join_only_active_events=true;
$ec3->join_post2cat=true;
else:
// Hide all events
$where.=" AND ec3_post2cat.category_id!=$ec3->event_category ";
// !!! SW Begin
// Need to explicitly qualify category_id column references
// i.e. category_id becomes $wpdb->post2cat.category_id
$pattern = '/([^.])category_id/i';
$where =
preg_replace($pattern,'\\1'.$wpdb->post2cat.'.category_id',$where);
// !!! SW End
$ec3->join_post2cat=true;
endif;
i.e. I am replacing 'category_id' where there is no leading '.' (and hence
the column is not fully qualified with a table name) with
$wpdb->post2cat.'.category_id', giving a fully qualified column name.
This seems to be working well for me (WP 2.0.4).
Any thoughts on this fix?
Thanks,
Steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://penguin.firetree.net/pipermail/eventcalendar/attachments/20061003/491a87a3/attachment-0001.html
More information about the EventCalendar
mailing list