Adding classes to event categories

@Vladislav here is the compiled conversation we started:

Can we add classes to event categories so when events are displayed on the calendar they can be color coded and custom styled based on the event category? – Stuart @ NavigationAdvertising

yes, are you using the default plugin output? – Vladislav

i believe that is the default “archive plugin calendar” – Stuart @ NavigationAdvertising

it seems the categories aren’t added to classes by default, but you can add them by using the Eab_EventModel method “get_categories” – Vladislav

this might actually be a wise thing to add to a future release – Vladislav

@vladislav cool, that would be awesome. can you guide me into the Eab_EventModel method “get_categories” , is there something i read – Stuart @ NavigationAdvertising

there aren’t any documentation at the moment, except the one in the comments in the class itself. If you’re at least a bit comfortable with PHP, these might come in handy. The file is located in “lib/class_eab_event_model.php” – Vladislav

thanks, i’ll venture into it – Stuart @ NavigationAdvertising

I’d be happy to help you navigate the code, either here in live chat or in a community topic – Vladislav

that would be great – Stuart @ NavigationAdvertising

public function get_categories () {

$list = get_the_terms($this->get_id(), ‘eab_events_category’);

return is_wp_error($list) ? false : $list;

}

public function get_category_ids () {

$list = $this->get_categories();

if (!$list) return false;

$cats = array();

foreach ($list as $category) $cats[] = $category->term_id;

return $cats;

}

– Stuart @ NavigationAdvertising

you’ll probably want the get_categories one, not the get_category_ids (that will just return a list of the numeric IDs) – Vladislav

ok, will do – Stuart @ NavigationAdvertising

public function get_categories () {

$list = get_the_terms($this->get_id(), ‘eab_events_category’);

return is_wp_error($list) ? false : $list;

}

so can i put that function into the template? – Stuart @ NavigationAdvertising

yes – you can use it along these lines:

global $post;

$event = new Eab_EventModel($post);

$categories = $event->get_categories();

– Vladislav

so don’t modify class_eab_event_model.php at all, and take those snippets and intergreat them into the template file? – Stuart @ NavigationAdvertising

yes exactly – any changes to the Eab_EventModel class can have repercussions on the plugin functionality – plus, it’ll get overwritten on plugin update. The best approach would be to manipulate the output in the template file – Vladislav