MyBB Central

Full Version: alternate calendar text colour?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hello, I use the calendar quite abit on my website & most days are full of events. Sometimes with as many as 12 events in 1 day. I want to make the events distinguishable from one another on each day by using 2 text colours & having them alternate for events posted in each day.
Is this possible?
Thanks
MyBB version 1.2.* ?

If MyBB 1.2.* version >

Open calendar.php

Find
PHP Code:
?>
Add above
PHP Code:
function alt_calcol($reset=0)
{
    global 
$altcalcol$mybb;

    
$col1 $mybb->settings['publiceventcolor'];
    
$col2 "#FF55FF";

    if(
$altcalcol == $col1 && !$reset)
    {
        
$col $col2;
    }
    else
    {
        
$col $col1;
    }

    
$altcalcol $col;
    return 
$col;


Find ( should be in calendar_main action; bottom of the file )
PHP Code:
    $events = array();
    
// Load Events
    
$query $db->simple_select(TABLE_PREFIX."events""subject, private, date, eid""date LIKE '%-{$month}-{$year}' AND ((author='{$mybb->user['uid']}' AND private='yes') OR (private!='yes'))");
    while(
$event $db->fetch_array($query))
    { 

Add below
PHP Code:
        $altcalcol alt_calcol(); 
Change calendar_eventbit_public into

Code:
<a href="calendar.php?action=event&amp;eid={$event['eid']}" title="{$event['fullsubject']}"><span class="smalltext"><font color="{$altcalcol}">{$event['subject']}</font></span></a><br />

Change $col2 to the alternating color; $col1 is the setting in your Calendar Group.

Ex. 23July > http://www.thingiej.be/mybb/calendar.php
ahh thankyou, I have 1.2.12
I will try this Smile
mm i have problem. the only part i can find in the code that mentions calendar_eventbit_public is this

$templatelist = "calendar,calendar_eventbit_public,calendar_eventbit_private,calendar_addpublicevent,calendar_addprivateevent,calendar_addevent,calendar_event,calendar_daybit,calendar_daybit_today";
require_once "./global.php";

and this

eval("\$events[$eventdate[0]] .= \"".$templates->get("calendar_eventbit_public")."\";");

should i be entering the

<a href="calendar.php?action=event&amp;eid={$event['eid']}" title="{$event['fullsubject']}"><span class="smalltext"><font color="{$altcalcol}">{$event['subject']}</font></span></a><br />

in both places?

Thanks
calendar_eventbit_public is a template;

ACP - Templates - Modify/Delete - <yourset> - Calendar Templates - calendar_eventbit_public
Ahh yes silly me.
Ok its all done & working. But the events arent evenly different coulours. I have say 2 in red, then 1 in green, then 1 in red then 3 in green etc.
Hmz; will add more to mine and see what it does.

Edit:
Doesn't happen overhere, > http://www.thingiej.be/mybb/calendar.php
do you think maybe its something to do with the order the events are added in? because some events are added a few days after.

This is what my one is looking like at the moment.

calendar
peepo Wrote:do you think maybe its something to do with the order the events are added in? because some events are added a few days after.

Hmz; its due that. Crappy thing =P
Will try to find something.
Ahhh okie, hopefully there is a solution Smile
Pages: 1 2