Posted: January 21, 2019 at 5:32 pm
We’re using the technique of having one category for color and there other category for the actual category. The “color category” has the color assignment, and the actual category has no color. Unfortunately, not all of the color assignments are working. Searching the forum, there is a reference that the category terms are sorted alphabetically, and the first term determines the color. It’s a relatively old post, though, and this is not the behaviour we’re seeing. Specifically, this combination does not work: ID Name 126 LATTE 120 Strains, Aches & Pains (Ergonomics) This combination does work: ID Name 86 LIGHT BLUE 120 Strains, Aches & Pains (Ergonomics)
We have a EE4 Everything license and the EE version is update-to-date. Thanks! |
|
Hi there,
They are not, can I ask where you saw this?
The calendar uses So the reason your first example does not work is that the category you are using for the colours has a higher ID, meaning it will be second in the array. The second example has a lower ID, so its ‘first’. To test you can do this:
Obviously, you change If you want to confirm which category would be used from the above, it’s the first element in the array, the calendar uses reset() to pull that from the array so something like:
Add that at the bottom of the above snippet and it will show you the category that will be used. |
|
Thanks. So aside from deleting/editing categories so the “color categories” have a lower ID, there is no other method of changing the order? This is the post mentioning the alphabetical sort: https://eventespresso.com/topic/colored-categories-not-working-after-update/#post-153821
|
|
Thank you for the link. The problem is that filter is for the EE3 version of the calendar (which did eventually sort the categories alphabetically), as you are using EE4 that isn’t available as it stands.
Not for changing the order no, but you can add some CSS to force the calendar to display the correct colour. So for example, you could use:
Then make sure that the calendar adds all of the categories classes to the event, you do this in the settings for the calendar: Event Espresso -> Calendar -> Basic Settings. Make sure ‘Enable CSS for Categories’ is set to Yes. What that does is loop over every category on the event and adds it as a class on the output, so the above would then target a category of light-blue and hardcode the background colour using !important. I can add a feature request to add a filter on the categories returned by the above in the calendar, so you could then hook into that and set the order however you prefer to do it that way? |
|
This technique of using two categories, one with color, is an indirect way of assigning a specific color directly to a specific event. The feature we’d really like is the ability to set color directly on an event. Failing that, some ability to influence ordering would be appreciated. Thanks so much for your fast responses. |
|
Then you can do it with one category and target that specific category in the same way as above.
Assuming you have a method to set a colour on the event through a custom field (ACF for example)? You can do that with the filters already available within the calendar add-on.
You can pull the event object from the datetime and then the custom colour you set on the event and assign it back to the calendar datetime. |
|
The support post ‘Calendar Event Color by Category’ 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.