MyBB Community Forums

Full Version: Colors for Calendar Events
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Im wondering if there is a way to have 4 or 5 optional colors for public events in the calendar.

Anyone can help?

Thanks!
That's abit a lot of work for a little thing. It requires altering the events db table, changing templates, editing php codes. so ...
You could probably get away with doing colours in a predetermined colour (not chosen when creating the event) rather easily. ie, the first event in the month will be green, the second orange etcetc.

I've not tested this but try

calendar.php
Find
<?php
after add
$event_colours = array('F00', '0F0', '00F'); 

Find
eval("\$daybits .= \"".$templates->get("calendar_daybit")."\";");
before it add
$event_colour='';
if($events[$i] != '&nbsp;')
{
$event_colour = "style=\"background:#" . ($event_colours[$event_colour_count++ % count($event_colours)]) . "\"";
}

Edit template calendar_daybit

Replace
<td width="14%" height="90" class="trow1" valign="top">
with
<td width="14%" height="90" class="trow1" valign="top" {$event_colour}>

If it works and you need to change the colour, you can do so by editing the $event_colours array at the top.

Anything more complicated and it would require more work as zaher says.

(Note the above code could probably be made into a plugin but I'm at work so can't really make one)
I would introduce categories for events (hopefully this is part of the calendar rewrite for MyBB 1.4)and base the color of the event off the category.
Exactly what I need, laie_techie.

I guess the answer is: NOT POSSIBLE NOW.