Support

Home Forums Events Calendar Add-on Multiple Category Classes on Calendar

Multiple Category Classes on Calendar

Posted: May 16, 2013 at 9:38 am

Viewing 4 reply threads


Danielle Walton

May 16, 2013 at 9:38 am

We recently upgraded EE Calendar from 2.0.3 to 2.0.5.1.  We have numerous events with multiple categories; with the old calendar, a class was added for each category (i.e. if we had an event assigned to categories of “Adults” and “Kids”, a class would be added for each.)  Has this functionality been dropped with the new version?  We only see 1 category class instead of multiple category classes.

I output the JSON string passed by the espresso_calendar_do_stuff function and indeed, only one category is present.  Has anyone come across a fix for this?  It’s fairly imperative that we have this functionality.

 

Thanks!


Josh

  • Support Staff

May 16, 2013 at 11:51 am

Hi Danielle,

They made some changes to the way the category class names are queried because it was causing some serious performance issues (the calendar would stop loading if you hit a threshold of open events). There is an open ticket to work in a solution that uses fewer queries and outputs all the class names instead of just one.

In the meantime you could revert back to the previous version of the calendar.


Danielle Walton

May 16, 2013 at 12:30 pm

Cool Josh – thanks for the reply; will keep an eye out for the update.  I was able to modify the query and the way that the class names are stored in the $events array to get this to work in the meantime.


Josh

  • Support Staff

May 16, 2013 at 1:14 pm

Hi Danielle,

Which query did you modify and how? This information may be helpful to the developers who are working on this (it might be helpful to compare notes).


Danielle Walton

May 19, 2013 at 7:56 pm

Hey Josh,

Ideally I think I would have done a UNION so we could have a poor man’s OUTER JOIN, (since MySQL doesn’t support it).  Basically I edited the query  starting around line 217 in espresso-calendar.php and removed the GROUP BY e.id statement.  This returns several rows for  each event but each one has the different category.  So that only one of each event appears on the calendar, when looping through the events, I put each event into the $events array with the $event->id as the key. If the key already exists, I simply add the new class the to the $events[$event->id]['className'] string like so:

$events[$event->id]['className'] .= isset($event->category_identifier) && !empty($event->category_identifier) ? " ".$event->category_identifier : '';

Finally, because a JSON string with numeric keys broke the calendar, I stripped the numeric keys from the finalized array:

$events = array_values($events);

As I said, it’s probably not the most elegant solution, but it seems to work fairly well without having to query each event individually as was the case in the old version.

Hope this helps — let me know if you have any questions.

Viewing 4 reply threads

The support post ‘Multiple Category Classes on Calendar’ 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