Colors of Categories not working
-
Hi and thanks for the plugin, this is the most promising looking one form my purposes.
I saw a resolved topic similar to what I’m to ask, but it doesn’t work for me. In my calendar view, all events have the default category color instead of the one I assigned to them.
When inspecting the item in the front-end, I did not find anything to distinguish classes of different categories. Did I configure it incorrectly? I checked all the setting thrice… Any help would be much appreciated.
Cheers,
Lidere
-
Here are some calendar examples on the demo page: https://eventsmanager.site/calendar/normal-calendar/
Can you provide a link to your event page?
Hi @joneiseman
Thanks for your reply. I tested both shortcodes and changed the entry of the page which displays the calandar. Still only get the default color.
Then I filtered a category and did not find any results, so I guess I have trouble because the taxonomies are messed up (I have tested other calendar plugins earlier)
I will check and post the results here.
Hi @joneiseman
I set up my page completely new, from scratch. I also created a new database. I installed your plugin and Force Login only since my website is intended for my family only. Then I tested with another theme. I don’t get it working. I tried for hours and went through all the setting looking for whatever could cause this.
I only see the default color. And when filtering for event categories, I get no result despite having a recurring one in that category.
In the backend, it shows there’s one event in a certain category, but on the frontend it is not. I’m logged in as an admin. Do you have any idea left what could cause this? I’d love using this plugin. The overall usability and minimalistic design is perfect for my intentions.
I think the problem might be related to the issue with caterories and recurring events reported here: https://wordpress.org/support/topic/problems-with-category-3/
Hopefully, @msykes will fix this in the next release.
-
This reply was modified 8 months ago by
joneiseman.
Thanks. Marking this tread as resolved and lookin forward for the updated plugin.
Hey @joneiseman,
working fix for version 7.1.7 for the problem of default color being displayed when showin recurring events:
Replace the function in em-event.php:
public function get_colors( $css_vars = false ){
$orig_color = $this->get_option('dbem_category_default_color');
$color = $borderColor = $orig_color;
$textColor = '#fff';
if ( $this->get_option('dbem_categories_enabled') ) {
$categories_obj = $this->get_categories();
// --- FIX: Fallback to Parent if Recurrent event ---
if ( empty($categories_obj->categories) && ($parent = $this->get_parent()) ) {
$categories_obj = $parent->get_categories();
}
// --- End of Fix ---
if ( !empty($categories_obj->categories) ) {
foreach ( $categories_obj->categories as $EM_Category ) {
/* @var $EM_Category EM_Category */
if ( $EM_Category->get_color() != '' ) {
$color = $borderColor = $EM_Category->get_color();
if ( preg_match("/#fff(fff)?/i", $color) ) {
$textColor = '#777';
$borderColor = '#ccc';
}
break;
}
}
}
}Worked for me. Maybe you could include this or an adapted version of this into the next update.
Regards
-
This reply was modified 7 months, 2 weeks ago by
lidere. Reason: typo
Hey @joneiseman,
me again. The fix above only works for desktop views. For mobile, this additional fix goes into section-dates.php:
replace the following code:
$EM_Category = $EM_Event->get_categories()->get_first();
if( $EM_Category ) {
$colors[] = $EM_Category->get_color();
} else {
$colors[] = em_get_option('dbem_category_default_color');
}with this:
$event_colors = $EM_Event->get_colors(false); // false = correct colors
$colors[] = $event_colors['background-color'];Cheers
Hi @lidere
Thanks for the suggested fixed.
I sent a message to @msykes so hopefully this will get fixed in the next release.
Best Regards,
Jon
-
This reply was modified 7 months, 2 weeks ago by
joneiseman.
Hello, just confirming that this will get fixed, the fix is further up into how the underlying way recurrences work (they don’t have post IDs associated with them – therefore taxonomies are inhereted from the parent recurring event) and that will in result fix this issue.
HI I add the patch at the end of the em_events.php; but the site does'nt work with the modify file
}
public function get_colors( $css_vars = false ){
$orig_color = $this->get_option('dbem_category_default_color');
$color = $borderColor = $orig_color;
$textColor = '#fff';
if ( $this->get_option('dbem_categories_enabled') ) {
$categories_obj = $this->get_categories();
// --- FIX: Fallback to Parent if Recurrent event ---
if ( empty($categories_obj->categories) && ($parent = $this->get_parent()) ) {
$categories_obj = $parent->get_categories();
}
// --- End of Fix ---
if ( !empty($categories_obj->categories) ) {
foreach ( $categories_obj->categories as $EM_Category ) {
/* @var $EM_Category EM_Category */
if ( $EM_Category->get_color() != '' ) {
$color = $borderColor = $EM_Category->get_color();
if ( preg_match("/#fff(fff)?/i", $color) ) {
$textColor = '#777';
$borderColor = '#ccc';
}
break;
}
}
}
}
?>Hi @lambert49
I would wait for @msykes to release a fix for this.
OK I hope it will be not too long
I use 7.2.2 so there was release since the first post
-
This reply was modified 5 months, 1 week ago by
lambert.
-
This reply was modified 8 months ago by
You must be logged in to reply to this topic.