Support

Home Forums Custom Files Add-on (EE3) Custom Espresso Table with Categories

Custom Espresso Table with Categories

Posted: August 31, 2012 at 4:14 am

Viewing 4 reply threads


mblatch

August 31, 2012 at 4:14 am

I need to build a custom table of events which includes extra meta fields. I want to include the event categories as CSS classes on the table. I am customising espresso_table.php. Can I get a hint on what SQL query I need to run to pull out these classes? [EVENT_ESPRESSO_CATEGORY] shortcode seems to have all the categories included but I’m getting lost trying to follow the source for that function. Thanks in advance!


Chris Reynolds

  • Support Staff

September 4, 2012 at 10:35 am

Are you just looking for category names/ids?


mblatch

September 10, 2012 at 7:05 am

Thanks as always Chris, didn’t see your reply till now. Yes I want to print the category name/id ( category_identifier field from the database) on each event – I need to color-code the table according to category, and want to use a CSS class like with WP post categories in the Loop.


Chris Reynolds

  • Support Staff

September 10, 2012 at 5:39 pm

It’s supposed to do that anyway, but for some reason the $category_identifier variable isn’t being passed to the event list template. This fills the variable so it will add it automatically to the div container, just add this somewhere in your event_list_display.php (like under all the status variables):

$category_identifier = $wpdb->get_var( "SELECT c.category_identifier FROM ". EVENTS_DETAIL_TABLE ." e JOIN " . EVENTS_CATEGORY_REL_TABLE . " r ON r.event_id = e.id JOIN " . EVENTS_CATEGORY_TABLE . " c ON c.id = r.cat_id WHERE e.id = ".$event_id );


mblatch

September 14, 2012 at 8:13 am

Thanks Chris!

In case anyone was curious the exact code I used was:

$CSSclass = $wpdb->get_var( "SELECT GROUP_CONCAT(c.category_identifier SEPARATOR ' cat-') as cssclass 
FROM ". EVENTS_DETAIL_TABLE ." e
JOIN " . EVENTS_CATEGORY_REL_TABLE . " r ON r.event_id = e.id 
JOIN " . EVENTS_CATEGORY_TABLE . " c ON c.id = r.cat_id 
WHERE e.id = ".$event->id );

So as to get all category identifiers attached to an event.

Viewing 4 reply threads

The support post ‘Custom Espresso Table with Categories’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso