OK, I think I have this now, bear with me as I describe the steps necesarry...
1. CREATE NEW FUNCTION
in the functions.inc.php file add this new function:
- Code: Select all
function get_week_number($timestamp) {
$d = getdate($timestamp);
$days = iso_week_days($d["yday"], $d["wday"]);
if ($days < 0) {
$d["yday"] += 365 + is_leap_year(--$d["year"]);
$days = iso_week_days($d["yday"], $d["wday"]);
} else {
$d["yday"] -= 365 + is_leap_year($d["year"]);
$d2 = iso_week_days($d["yday"], $d["wday"]);
if (0 <= $d2) {
/* $d["year"]++; */
$days = $d2;
}
}
return (int)($days / 7) + 1;
}
2. ADD EMPTY CELL TO TITLE ROW
At the beginning of the dra_cal() function, just after the <tbody> is opened, add this to the first row (ie BEFORE we write the week day titles):
- Code: Select all
<td> </td>
it should look like this:
- Code: Select all
<tbody>
<tr>
<td> </td>
3.ADD FIRST ROW WEEK NUMBER
After the title columns (ie the bit where it writes "M","T","W" etc....
add this to the first date row:
- Code: Select all
<td>'.get_week_number(mktime(0,0,0, $month,1, $year)).'</td>
This will calclulate the number for the first week basing it on the fact that the month always starts with the number 1

4. ADD WEEK NUMBER TO OTHER ROWS
We will now use the code that adds a new row every 7 days to add the week numbers as well.
Find this code: (bear in mind that you might have modified this for one of your other requests but I will use the "original" version for any others who might come across this thread and request the same feature):
- Code: Select all
if($week_day == 0){
$the_cal .= "</tr><tr>";
++$cal_row_counter;
}
and replace with this:
- Code: Select all
if( ($week_day == 0) && ($day_counter<$days_in_this_month )){
if(CAL_START_DAY=="sun") $date_timestamp = mktime(0,0,0, $month,$day_counter,$year);
else $date_timestamp = mktime(0,0,0, $month,($day_counter+1),$year);
$the_cal .= '
</tr>
<tr>
<td>'.get_week_number($date_timestamp).'</td>
';
++$cal_row_counter;
}
Well, that "should" be it, I realise that your version is slightly diferrant as we have been adding different mods, but hopefully you will now be "used" to the code and be able to add it now problems

Let me know how it goes

Chris