tips and tricks for movable type

calendar cell background colors
May 07, 2003

This is a little coding tip on how to have the background colors of your calendar cells change depending on whether or not you have entries for that day.

Replace this part of the default calendar code:

<td align="center"><span class="calendar">

with this:

<td <MTCalendarIfEntries>bgcolor="#FFFFFF" </MTCalendarIfEntries><MTCalendarIfNoEntries>bgcolor="#000000" </MTCalendarIfNoEntries>align="center"><span class="calendar">

Change #FFFFFF to the value of the color you want when there is an entry, and change #000000 to the value of the color you want when there are no entries for that day.

(Note that there's a space following "#FFFFFF" and "#000000" in that code.)

Comments

Girlie, how would you make the background show up when you use your (remember this) php code for putting two months of calendar in a row. (note: leading "less than" sign replaced with begin parens so as to make it visible here!)

(div align="center" class="calendar">
(?php
(MTArchiveList lastn="2" archive_type="Monthly">
$monthlyarchivereverse[] =
"

(tr>
(th abbr=\"Sunday\" align=\"center\">Sun
(th abbr=\"Monday\" align=\"center\">Mon
(th abbr=\"Tuesday\" align=\"center\">Tue
(th abbr=\"Wednesday\" align=\"center\">Wed
(th abbr=\"Thursday\" align=\"center\">Thu
(th abbr=\"Friday\" align=\"center\">Fri
(th abbr=\"Saturday\" align=\"center\">Sat
(/tr>
(MTCalendar month="this">
(MTCalendarWeekHeader>
(td bgcolor=\"#00CC00\" align=\"center\">
\">
(MTCalendarIfNoEntries>
(MTCalendarIfBlank> (/MTCalendarIfBlank>
(MTCalendarWeekFooter>
(/MTCalendar>
(/table>";
(/MTArchiveList>
$monthlyarchive = array_reverse($monthlyarchivereverse);
foreach($monthlyarchive as $temp) {
echo $temp;
}
?>
(/div>

by Todd | 05.17.03 07:25 PM

Using the code I posted in Two Calendars Reverse Sort, replace:

<td <MTCalendarIfToday>bgcolor=\"#EEEEEE\"</MTCalendarIfToday> align=\"center\">

with:

<td <MTCalendarIfEntries>bgcolor=\"#FFFFFF\" </MTCalendarIfEntries><MTCalendarIfNoEntries>bgcolor=\"#000000\" </MTCalendarIfNoEntries>align=\"center\">

I think that should do it.

by girlie | 05.18.03 10:46 AM

I'll give that a shot, but you know, I was hoping to use both (greedy little bastard that I am): the today tag for one color, the ifentries color for another color...

I tried putting all three in there and it just said "huh"? (or something more serious and PHP relevant)

And, yes, the code is from that post (verbatim). What can I say, I copy your code whenever I can :)

Gratefully and graciously,

Todd

by Todd | 05.18.03 11:02 AM

Girlie,

Thanks for the info. How would you go about changing the color of the individual text of the cell for an entry? (As with Todd's comment, the leading angle bracket has been replaced with an open paren.)

I tried changing the code to reflect an additional css class:

(MTCalendarIfEntries>
(MTEntries lastn="1">
(a class="calendarlink" href="($MTEntryPermalink$>">($MTCalendarDay$>(/a>
(/MTEntries>
(/MTCalendarIfEntries>

But that didn't work. Any ideas?

Thanks,
Andy

by Andy | 07.07.03 12:38 PM

Well I gave it a whirl as my 1st mod to my blog. It gave me two colored blocks on either side of the date that had an entry which I do not know is the intended effect (I assume that the bgcolor was suppose to be behind the number).

by holiday | 08.05.03 01:17 AM

holiday - try editing the background for .calendar in your stylesheet

by Candice | 09.06.03 05:51 AM

hi ,
please u can give me how should i hang up all they mobile normale i am relly thanks to u will u please help me for

by talha | 09.23.03 11:02 AM

Hi, I've tried adding the bgcolor in the index template as you posted above but the code came out as text. I did remember to include the space as you said. I'm thinking there should be a way to do it in the CSS. Anyhow, any ideas?
Thanks. :)

by Holiday [TypeKey Profile Page] | 09.05.04 09:39 PM

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

TrackBack: 4
(URL: http://www.thegirliematters.com/sf/mt-track.cgi/149)

» MT Tweaks
Excerpt: General, indispensible links for MT setup and configuration include: Movable Type, the girlie matters, Empty Pages, Scriptygoddess, and CSS Zen Garden. To minimize the tehno-babble on this blog while keeping track of this behemoth project, here is the ...
Weblog: patchwork progression
Tracked: 09.02.03 01:45 PM

» Adjustments
Excerpt: Added some mods today, including "calendar cell background colors" and the previous and next calendar function. More to come....
Weblog: lingosphere daily
Tracked: 11.12.03 08:36 PM

» Table Cell Background Colors
Excerpt: [the girlie matters] tips and tricks: calendar cell background colors...
Weblog: Living Dead Girl
Tracked: 10.19.04 10:45 AM

» Table Cell Background Colors
Excerpt: [the girlie matters] tips and tricks: calendar cell background colors...
Weblog: Tutorials
Tracked: 10.21.04 06:56 PM