Hi All,
I have some code that outputs a year calendar and shows the months respectively. There is a screen shot here:
calendar screen shot
The problem is I don't know how to get the year to follow the month. e.g. October 2006, November 2006, December 2006, January 2007 etc.
The calendar is compiled by calling the function showcalendar(). The code below:
function showcalendar($event_file_param="")
{
GLOBAL $template_dir,$cfg_dir,$events_list,$event_set;
include_once($cfg_dir.'template_class.php');
$T = new YaTemplate($template_dir);
$T->SetFile("main","all_month.tpl");
//$T->SetBlockTree("main", array("event_style","row_month"=>"one_month",'event_color'));
$T->SetBlockTree("main", array("event_style","row_month"=>"one_month",'hor_events','ver_events'));
$events_list=LoadFromFile($cfg_dir.'event_list.txt');
$event_file=getEventFile($event_file_param);
$event_set=$event_file_param;
$events=LoadFromFile($event_file);
$customize=loadCustomize($cfg_dir.'customize.txt');
setFontColorVar($T,$customize,'month');
setFontColorVar($T,$customize,'t_days');
setFontColorVar($T,$customize,'t_wdays');
setFontColorVar($T,$customize,'past_days');
setFontColorVar($T,$customize,'w_days');
setFontColorVar($T,$customize,'prev_next');
setFontColorVar($T,$customize,'current_day');
for ($i=0;$i<=sizeof($events_list);$i++)
{
$T->SetVar('event','event'.$i);
$T->SetVar('bg',$customize[fc]['event'.$i][bgcolor]);
$T->SetVar('font',$customize[fc]['event'.$i][font]);
$T->SetVar('size',$customize[fc]['event'.$i][size]);
$T->SetVar('color',$customize[fc]['event'.$i][color]);
$T->ParseBlock('event_style');
}
$T->SetVar('table_bg',$customize['table_bg']);
$T->SetVar('table_border_width',$customize['table_border_width']);
$T->SetVar('table_border_color',$customize['table_border_color']);
$T->SetVar('padding',$customize['padding']);
$T->SetVar('spacing',$customize['spacing']);
$month=date('n');
$year=date('Y');
$month=$month+$customize[start_m];
if ($month>13)
{
$month=$month-12;
$year++;
}
$date=mktime(0,0,0,$month,1,$year);
$extra_row=false;
$month1=$month;
$year1=$year;
for ($i=0;$i<$customize[m_number]*$customize[row_number];$i++)
{
$date=mktime(0,0,0,$month1,1,$year);
$day_of_week=date('w',$date);
if ($day_of_week==0) $day_of_week=7;
$day_of_week--;
$day_of_week+=date('t',$date);
if ($day_of_week/7>5)
{
$extra_row=true;
break;
}
$month1++;
if ($month1==13)
{
$month1=1;
$year1++;
}
}
for ($i=0;$i<$customize[m_number]*$customize[row_number];$i++)
{
$date=mktime(0,0,0,$month,1,$year);
$one_month=print_month($date,$events[$month],'',$customize,$extra_row);
$T->SetVar('month',$one_month);
$T->ParseBlock('one_month');
if (($i+1) % $customize[m_number]==0)
{
$T->ParseBlock('row_month');
$T->CleanVar('one_month');
}
$month++;
if ($month==13)
{
$month=1;
$year++;
}
}
if (is_array($events_list))
{
while (list($key,$val)=each($events_list))
{
$T->SetVar('name',$val['name']);
$T->SetVar('event_class','event'.$key);
if ($customize[menu_layout]!=1)
{
$T->ParseBlock('hor_events');
$T->SetVar('ver_events','');
}
else
{
$T->ParseBlock('ver_events');
$T->SetVar('hor_events','');
}
}
/* reset($events_list);
while (list($key,$val)=each($events_list))
{
$T->SetVar('color',$customize['event_color'][$key]);
$T->ParseBlock('event_color');
}
*/
}
$T->Parse("OUT", "main");
$T->PrintOut();
}[/B][/COLOR]
If anyone out there knows how I could incorporate it into the function I would be very grateful indeed.
Cheers
Nigel