[EventCalendar] showing only some of event-types

Johan Michaelsen johan.orgel at post.tele.dk
Wed May 30 12:58:49 UTC 2007


Hi

Some time ago I posted a question about  the "ec3_get_events"  
function, as I only wanted to show certain types of events in the  
sidebar.

Now I managed to make a simple (and probably risky) mysql-query - and  
it runs separately from the WP-installation - I mean, it doesn't call  
any of the wp-functions.

I post it here, so that you can comment on it or use it if you like.  
(As I said, it is probably risky because I use a manual connection to  
the database...)

I made a template-file in folder of the theme I use. And I call it  
from the sidebar.php
----------------------------------------------
<?php include (TEMPLATEPATH . '/specialKald5C.php'); ?>
----------------------------------------------

Here's the "specialKald5C.php'":
----------------------------------------------
<?php

$db = mysql_connect("database-host", "user-name", "password");

mysql_select_db("database-name",$db);

$result = mysql_query("SELECT DISTINCT wp_posts.ID,  
wp_posts.post_title, wp_posts.guid, wp_post2cat.category_id,  
DATE_FORMAT(wp_ec3_schedule.start,'%d. %M %Y kl. %H:%i') AS st_date  
FROM wp_posts JOIN wp_post2cat JOIN wp_ec3_schedule WHERE  
(wp_post2cat.category_id = 4 OR wp_post2cat.category_id = 5) AND  
wp_posts.ID = wp_ec3_schedule.post_id AND wp_post2cat.post_id =  
wp_posts.ID AND wp_ec3_schedule.start > now() ORDER BY  
wp_ec3_schedule.start ASC",$db);



if ($myrow = mysql_fetch_array($result)) {

//here was originally the line up for a table-based presentation of  
the list
//echo "<table border=1 cellspacing=0 cellpadding=4>\n";
//echo "<tr><td>start-dato</td><td>Titel</td></tr>\n";

do {
//This is a manual conversion of the month-names to danish
$word_to_be_replaced = array("January", "February", "March", "April",  
"May", "June", "July", "August", "September", "October", "November",  
"December");
$replace_with = array("januar", "februar", "marts", "april", "maj",  
"juni", "juli", "august", "september", "oktober", "november",  
"december");

$replace_in_string = $myrow['st_date'];

		printf("<ul><li>%s</li><ul><li><a href=\"%s\">%s</a></li></ul></ul> 
\n",
		str_replace($word_to_be_replaced, $replace_with,  
$replace_in_string), $myrow['guid'], $myrow['post_title'], "");

   } while ($myrow = mysql_fetch_array($result));

	//and the closing tag for the table
	//echo "</table>\n";

} else {

	echo "No future arrangements at the moment";	

}
?>

----------------------------------------------

You could expand or narrow the query search within the lines

....WHERE (wp_post2cat.category_id = 4 OR wp_post2cat.category_id =  
5) .....

----------------------------------------------
About the architechture of my event-categories

My event-category is nr 2 and all the different types of events are  
sub-cats of this category:

Arrangements:    (cat 2)
  -  Concerts           (cat 4)
  -   Services           (cat 5)
  -  Rehearsals      (cat 3)
  -  Workshops      (cat 13)     and so on......

----------------------------------------------
Well I actually wanted to be able to modify the ec3-function - but my  
php and mysql skills were not good enough to dig into the complicated  
files. So I made my own dirty call.
If you think it's a bad idea to use the method mentioned above, I'd  
like to hear from you....


best regards
Johan






More information about the EventCalendar mailing list