Welcome Guest, Not a member yet? Register   Sign In
[3.1.4 modification] modify calendar library, add extra column before calendar
#4

(This post was last modified: 05-22-2017, 12:53 PM by eagle00789. Edit Reason: added screenshot )

if you want a quick and dirty method like me, you can do the following:
the mentiond line numbers represent the original line numbers from the original calendar.php file. that is why the changes are in reverse order, from the bottom up:
Copy the system/libraries/calendar.php file to Application/libraries/MY_calendar.php
Go to line 526 and replace it with the following text:

PHP Code:
foreach (array('table_open''table_close''heading_row_start''heading_previous_cell''heading_title_cell''heading_next_cell''heading_row_end''week_row_start''week_row_before_cell''week_day_cell''week_row_end''cal_row_start''cal_row_before''cal_cell_start''cal_cell_content''cal_cell_no_content''cal_cell_blank''cal_cell_end''cal_row_end''cal_cell_start_today''cal_cell_content_today''cal_cell_no_content_today''cal_cell_end_today''cal_cell_start_other''cal_cell_other''cal_cell_end_other') as $val
Go to line 336 and paste the following before the line already there

PHP Code:
           if (array_key_exists('cal_row_before'$this->replacements))
 
           {
 
               $maxday $day-1;
 
               if ($maxday >= 32)
 
               {
 
                   $maxday max(array_keys($data));
 
               }
 
               $out str_replace('{to_day}'$maxday$out);
 
           
Go to line 297 and paste the following before the line already there

PHP Code:
                       if (array_key_exists('cal_row_before'$this->replacements))
 
                       {
 
                           $out str_replace('{from_day}'$day$out);
 
                       
Go to line 284 and paste the following before the line already there
PHP Code:
           if (array_key_exists('cal_row_before'$this->replacements))
 
           {
 
               $out .= $this->replacements['cal_row_before'];
 
           
Go to line 271 and paste the following before the line already there
PHP Code:
        if (array_key_exists('week_row_before_cell'$this->replacements))
        {
 
           $out .= $this->replacements['week_row_before_cell'];
 
       
Replace line 51 with the line below

PHP Code:
class MY_Calendar extends CI_Calendar 
Now just call your extra calendar like below

PHP Code:
       $this->load->library('calendar'$prefs);
 
       $this->load->library('MY_calendar'$prefs); 
and just use the normal functions like you are used to.
Now you can use the following fields in your template (with examples included)

PHP Code:
           {week_row_before_cell}<td>&nbsp;</td>{/week_row_before_cell}
 
           {cal_row_before}<td>{from_day}-{to_day}</td>{/cal_row_before
The field week_row_before is to accommodate the extra column in the week name row
The field cal_row_before is the extra cell before each week row. In this field, you can use the fields from_day and to_day to use the first and last day of that week in your extra cell.
View a demo (partial screenshot) below:
   
Reply


Messages In This Thread
RE: modify calendar library - by skunkbad - 05-20-2017, 03:03 PM
RE: modify calendar library - by ivantcholakov - 05-21-2017, 06:27 AM
RE: modify calendar library - by eagle00789 - 05-22-2017, 12:46 PM



Theme © iAndrew 2016 - Forum software by © MyBB