Support » Plugin: Events Manager » [Plugin: Events Manager] Cannot figure howto user category colors in calendar-small.php file

  • Resolved Lanttu42


    Well this is mind boggling. I am using latest version of Events Manager and I am trying to deploy this plugin to my customer who has this simple request; category colors should be used as a table-cell background color in widget calendar (calendar-small.php).

    After I’ve tried possible every trick that there is in this forum, I am starting to believe that this cannot be solved with another cup of hot coffee. I need some advices… please…

    What I have done so far:

    I have copied this calendar-small.php to my template folder as mentioned in tutorials – I confirmed that with simple echo and to make sure that I am using right file.

    Then I tried just simple edit <td…> line and added:
    <td class="<?php echo $class;?>" style="background-color: #_CATEGORYCOLOR;">
    and I end up with this:
    <td class=”eventful” style=”background-color: #_CATEGORYCOLOR;”>

    So that didn’t work and obviously shortcodes are not mentioned to use inside PHP templates?

    SO – Next idea was promising …
    I added this:
    global $EM_Event;
    to first <?php ?> part and then modified the same <td…> line as follows:
    <td class="eventful" style="background-color:<?php echo $EM_Event->output("#_CATEGORYCOLOR"); ?>">
    which gives me this:
    <b>Fatal error</b>: Call to a member function output() on a non-object in <b>/biz/0/teams/html/www/wp-content/themes/twentyten/plugins/events-manager/templates/calendar-small.php</b> on line <b>38</b>

    I have also tried to get the category ID out of the $cell_data but my PHP skills are not there yet.. When I print_r() it, I see that it is there, but I cannot figure out the corrent $cell_data[][][]… combination to get it out. 🙁 I could use that ID to create CSS classes for every category that we are using.

    Any ideas, how I can use category color (or image) as a background in small calendar is welcome…

Viewing 3 replies - 1 through 3 (of 3 total)
  • you can try this


    					$class .= "-".$cell_data['type'];

    you can insert this

    					if ( !empty($cell_data['events']) ){
    						foreach( $cell_data['events'] as $EM_Event ){
    						  $category_color = $EM_Event->output("#_CATEGORYCOLOR");

    removed global $EM_Event;

    This is my solution to modify small calendar. Modifying <td> tag from calendar-small.php with part of the above code and adding an ‘echo‘ call to $category_color:

    <td class="<?php echo $class; ?>" style="background-color:<?php
    					if ( !empty($cell_data['events']) ){
    						foreach( $cell_data['events'] as $EM_Event ){
    						echo  $category_color = $EM_Event->output("#_CATEGORYCOLOR");

    And then my small calendar starts showing Category Colors as background-color. Hope this helps someone.

    Really good solution, JordiWP. I have tested it, and its work perfect. Unfortunately I also wanted to use the option “Show long Events” and this option is overrighting all colors.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Events Manager] Cannot figure howto user category colors in calendar-small.php file’ is closed to new replies.