Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#89 add Project color to Events

Unstable_(example)
open
nobody
5
2014-08-09
2007-08-23
Tsan-Kuang Lee
No

To color the events in calendar view, there are 2 files to change in /modules/calendar/

In links_events.php, change this line (line 36, or about 5th from the buttom):

. '<td><a href="' . $url . '" title="'.$row['event_description'].'"><span class="event">'.$row['event_title'].'</span></a>'

Into this one:

. '<td><a href="' . $url . '" title="'.$row['event_description'].'"><span class="event" style="color:'.bestColor($row['color']).';background-color:#'.$row['color'].'">'.$row['event_title'].'</span></a>'

In calendar.class.php, in function getEventsForPeriod, in the first "foreach" loop (line 523), after

$$query_set = new DBQuery;
$$query_set->addTable('events', 'e');
$$query_set->addQuery('e.*');

add the following:

$$query_set->addQuery('p.project_color_identifier AS color');
$$query_set->addJoin('projects', 'p', 'p.project_id = e.event_project');

and comment out the following line below the "if" statement:

// $$query_set->addJoin('projects', 'p', 'p.project_id = e.event_project');

Or you can directly find them in the attached file.

Discussion

  • Tsan-Kuang Lee
    Tsan-Kuang Lee
    2007-08-23

    color events in calendar view

     
  • Hi Tsan-Kuang Lee,
    I have tried this, but I do "Add Event" and do not select any project (just keep it as "All"), my event is white, and the problem is that my background is with too, them in calender view I cannot see this event, just the icon. (I am using default dotproject interface - default clean style).Thanks.

     
  • Tsan-Kuang Lee
    Tsan-Kuang Lee
    2009-06-23

    Hi,

    Sorry about that. The Core routine for BestColor does not take care of an empty string. Here's the quick fix in /modules/calendar/links_events.php:

    if ($row['color'] == "") {
    $text_color = 'black';
    $text_color_backgrond = 'white';
    } else {
    $text_color = bestColor($row['color']);
    $text_color_backgrond = '#'.$row['color'];
    }
    $link['text'] = '<table cellspacing="0" cellpadding="0" border="0"><tr>'
    . '<td><a href=' . $url . '>' . dPshowImage( dPfindImage( 'event'.$row['event_type'].'.png', 'calendar' ), 16, 16)
    . '</a></td>'
    . '<td><a href="' . $url . '" title="'.$row['event_description'].'"><span class="event" style="color:'.$text_color.';background-color:'.$text_color_backgrond.'">'.$row['event_title'].'</span></a>'
    . '</td></tr></table>';

    This way, if the background is not set, it falls back to the default white background and black foreground.