Advance 12 Months

Posts about customizing the look and feel; Describe and link to your custom templates for phpicalendar 2.X

Advance 12 Months

Postby Paul_Jones » Sun Mar 07, 2010 3:21 pm

I have spent today customising iCalender.
I nearly have it how I like but have one last thing to get right.

I have decided to just use month view (no day, week or year views) and have removed jump lists except for 'year' and 'month'.
Jumping forward a month at a time is good but the year jump list brings up the year.php which I do not want (as I then have to use the month jump list to go to the desired month view).
Is there any way to modify this so it stays in month view but jumps forward exactly 12 months (so if currently in month view for March 2010, setting year 2011 would show March 2011 im month view)?

Many thanks.
Paul_Jones
Member
 
Posts: 16
Joined: Sun Mar 07, 2010 8:01 am

Re: Advance 12 Months

Postby Paul_Jones » Tue Mar 09, 2010 3:06 pm

Paul_Jones wrote:I have decided to just use month view (no day, week or year views) and have removed jump lists except for 'year' and 'month'.
Jumping forward a month at a time is good but the year jump list brings up the year.php which I do not want (as I then have to use the month jump list to go to the desired month view).
Is there any way to modify this so it stays in month view but jumps forward exactly 12 months (so if currently in month view for March 2010, setting year 2011 would show March 2011 im month view)?


This is much harder than I thought it would be :(
I have uploaded an image of my set-up (see below) .
You can see there are just 2 jump lists. The top one is the one I want to recode.
Instead of opening the year.php I want it to open the month.php but 12 months in the future (or past) and not 1 month (which is what the bottom jump list will do).
Now I would have thought it would be possible to just to reuse the code for the month jump list but to add/deduct 12 months instead of 1 month. Then to change the action of the top jump list item to use this modified code instead of opening the year.php.
My problem is I cannot even figure out where to start :cry:

Can anyone lease give me an indication of if this would be possible and maybe a pointer to where I need to change the code?

Many thanks if you can and if not, thanks for taking the time to look :)

Image
Paul_Jones
Member
 
Posts: 16
Joined: Sun Mar 07, 2010 8:01 am

Re: Advance 12 Months

Postby Paul_Jones » Tue Mar 09, 2010 3:36 pm

OK, it seems I have to modify function list_years() in list_functions.php
I have had a little go at list and have it working to some degree but it is far from how I want it.
Paul_Jones
Member
 
Posts: 16
Joined: Sun Mar 07, 2010 8:01 am

Re: Advance 12 Months

Postby Paul_Jones » Tue Mar 09, 2010 4:00 pm

I have this working exactly how I want it.

I cannot believe it was as easy as changing the 3 references of year.php to month.php in function list_years()
It seems to be working OK and seems really quick.

Any PHP guru willing to give this a quick check and make sure there can be no negative effects to this method please :)

Code: Select all
function list_years() {
   global $getdate, $this_year, $cal, $phpiCal_config;
   $year_time = strtotime($getdate);
   $return = '';
   for ($i=0; $i < $phpiCal_config->num_years; $i++) {
      $offset = $phpiCal_config->num_years - $i;
      $prev_time = strtotime("-$offset year", $year_time);
      $prev_date = date("Ymd", $prev_time);
      $prev_year = date("Y", $prev_time);
      $return .= "<option value=\"month.php?cal=$cal&amp;getdate=$prev_date\">$prev_year</option>\n";
   }
   
   $getdate_date = date("Ymd", $year_time);
   $getdate_year = date("Y", $year_time);
   $return .= "<option value=\"month.php?cal=$cal&amp;getdate=$getdate_date\" selected=\"selected\">$getdate_year</option>\n";
   
   for ($i=0; $i < $phpiCal_config->num_years; $i++) {
      $offset = $i + 1;
      $next_time = strtotime("+$offset year", $year_time);
      $next_date = date("Ymd", $next_time);
      $next_year = date("Y", $next_time);
      $return .=  "<option value=\"month.php?cal=$cal&amp;getdate=$next_date\">$next_year</option>\n";
   }
   
   return $return;
}


Once again , many thanks for your time :)
Paul_Jones
Member
 
Posts: 16
Joined: Sun Mar 07, 2010 8:01 am


Return to Customizing appearance

Who is online

Users browsing this forum: No registered users and 1 guest