All. In the past as a result of some great help from Gabriel Harrison I was
able to set a special color for today's date. I also added in a special
color for holidays. Below is the code. Enjoy!
#1 - In 'display.php' put in code like this:
...
// displays the day of the week and the following days of the week
// return XHTML data for the days
function display_days($day_count, $week_of_month, $month, $year)
{
global $db, $phpc_script, $config, $first_day_of_week;
if($day_count > 7) return array();
$day_of_month = ($week_of_month - 1) * 7 + $day_count
- ((7 + day_of_first($month, $year) - $first_day_of_week) % 7);
if($day_of_month <= 0 || $day_of_month > days_in_month($month, $year)) {
$html_day = tag('td', attributes('class="none"'));
} else {
$currentday = date('j');
$currentmonth = date('n');
$currentyear = date('Y');
// set whether the date is in the past or future/present
if ($month < 10) {
$month2 = "0". $month;
}
else {
$month2 = $month;
}
if ($day_of_month < 10) {
$day_of_month2 = "0". $day_of_month;
}
else {
$day_of_month2 = $day_of_month;
}
$curr_date = $year . "-" . $month2 . "-" . $day_of_month2;
mysql_connect("localhost", "-----", "-----");
mysql_select_db("calendar");
$result = mysql_query("SELECT * FROM phpc_holidays
WHERE Holiday_Date = '". $curr_date . "'")
or die('Could not look up holiday information; ' . mysql_error());
//echo $result;
if ($row = mysql_fetch_array($result)) {
$holiday = "Yes";
}
else {
$holiday = "No";
}
if($currentyear == $year && $currentmonth == $month && $currentday ==
$day_of_month) {
$current_era = 'today';
} elseif($holiday == "Yes") {
$current_era = 'holiday';
} elseif($currentyear > $year || $currentyear == $year
&& ($currentmonth > $month
|| $currentmonth == $month
&& $currentday > $day_of_month
)) {
$current_era = 'past';
} else {
$current_era = 'future';
}
if(can_add_event()) {
$html_day = tag('td', attributes('valign="top"',
"class=\"$current_era\""),
create_date_link('+', 'event_form',
$year, $month,
$day_of_month,
array('class="phpc-add"')),
create_date_link($day_of_month,
'display', $year, $month,
$day_of_month,
array('class="date"')));
} else {
$html_day = tag('td', attributes('valign="top"',
"class=\"$current_era\""),
create_date_link($day_of_month,
'display', $year, $month,
$day_of_month,
array('class="date"')));
}
$result = get_events_by_date($day_of_month, $month, $year);
...
#2 - In 'style.php' put in code like this:
#2a - At the top:
...
$bgtoday = BG_TODAY;
$bgholiday = BG_HOLIDAY;
$bgpast = BG_PAST;
$bgfuture = BG_FUTURE;
...
Note that these colors were set in 'index.php' just like the other colors:
...
define('BG_TODAY', '#00CED1'); // color for today's date
define('BG_HOLIDAY', '#DA70D6'); // holiday's date
define('BG_PAST', '#EEE8AA'); // past days, days already passed;
default = silver
define('BG_FUTURE', '#EEE8AA'); // future days; default = white
...
#2b - Near the bottom:
...
#calendar {
table-layout: fixed;
}
#calendar td {
text-align: left;
height: 80px;
overflow: hidden;
}
td.past {
background-color: <?php echo $bgpast ?>;
color: inherit;
}
td.today {
background-color: <?php echo $bgtoday ?>;
color: inherit;
}
td.holiday {
background-color: <?php echo $bgholiday ?>;
color: inherit;
}
td.future {
background-color: <?php echo $bgfuture ?>;
color: inherit;
}
td.none {
background-color: <?php echo $bgcolor2 ?>;
color: inherit;
}
table.phpc-main ul {
margin: 2px;
padding: 0;
list-style-type: none;
border-color: <?php echo $sepcolor ?>;
border-style: solid;
border-width: 1px 1px 0 1px;
background-color: <?php echo $bgcolore ?>;
}
....
--
Larry
|