Events Made Easy › Forums › How do I … › A few things (trying to extend the plugin)
Tagged: categories, category, extending
- This topic has 7 replies, 3 voices, and was last updated 14 years, 1 month ago by Franky.
-
AuthorPosts
-
Thu 30 Sep 2010 at 20:39 #42120AnonymousInactive
I have an event page and in the sidebar there is a list of categories (kind of like you might have on a frontpage). I was using dbem_get_categories() to pull all the categories in the database. The problem was it was pulling some categories for events that came and went (especially during dry months). The result was the user would click the category and get a ‘no events for this date’.
So I created this function:
function get_open_categories(){
global $wpdb;
$event_table = ‘wp_dbem_events’;
$categories_table = ‘wp_dbem_categories’;
$sql = “SELECT DISTINCT category_name FROM wp_dbem_categories, wp_dbem_events WHERE ( wp_dbem_events.event_category_id = wp_dbem_categories.category_id ) && ( event_end_date >= CURDATE() )”;
$open_cats = $wpdb->get_results($sql, ARRAY_A);
return $open_cats;
}
And it works great. I pasted it in my functions.php but when I try to paste it into the marcus-extras.php some sort of error where the page is not totally rendered. No PHP spitting out error codes, but the HTML box where it is called doesn’t show up.
I’ve never written a plugin, so I don’t know why that it happening. Can someone chime in on this?
Thu 30 Sep 2010 at 20:47 #44872AnonymousInactiveI’ve also extended this for locations:
function get_open_locations(){
global $wplogger;
global $wpdb;
$event_table = ‘wp_dbem_events’;
$categories_table = ‘wp_dbem_categories’;
$sql = “SELECT DISTINCT location_name FROM wp_dbem_locations, wp_dbem_events WHERE ( wp_dbem_events.location_id = wp_dbem_locations.location_id ) && ( event_end_date >= CURDATE() )”;
$open_cats = $wpdb->get_results($sql, ARRAY_A);
return $open_cats;
}
Thu 30 Sep 2010 at 21:24 #44873FrankyKeymasterWell … I don’t know what version you’re using, but the file called “marcus-extras.php” is no longer part of the code. That’s probably why it fails on you: you call a function that just isn’t there …
Thu 30 Sep 2010 at 21:31 #44874AnonymousInactiveAhh. Old plugin folder.. yikes.
Thu 30 Sep 2010 at 21:34 #44875AnonymousInactiveDeleting the old plugin doesn’t delete the database does it?
Thu 30 Sep 2010 at 22:51 #44876AnonymousInactiveNope it doesn’t.
Sun 17 Oct 2010 at 12:04 #44877AnonymousInactiveThis is just what I was looking for – only, I’m a PHP-illiterate. I’m getting a call to undefined function. Is there some add_action or init missing for the functions.php?
Sun 17 Oct 2010 at 17:27 #44878FrankyKeymasterThere’s no funtions.php included in events-manager.php. If you want these functions, add them to one of the existing files. Or if you want a file functions.php, make sure it gets included in events-manager.php. Eg. add a line
include(“functions.php”);
after
include(“eme_attributes.php”);
in that file.
-
AuthorPosts
- The forum ‘How do I …’ is closed to new topics and replies.